Top

A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded

FILES AND DIRECTORIES

Visual editor

  • 'Vi' sual editor
    • On startup 'vi' searches for the environment variable EXINIT, it contains the location (or NOT) of a file containing configuration commands.
    • If EXINIT is not defined 'vi' looks for a .exrc file in the HOME directory and uses configuration commands in it.
    • If no ~/.exrc file 'vi' looks in the current directory.

    The .exrc file can contain comments, 'ex' commands (e.g. :set showmode), map commands and macro definitions. Map commands help to customize the vi editor redefining keys when in command mode.

    VI has two operating modes:

    Command mode

    allows for navigation and command execution

    all commands, while in command mode, start with ':'

    Insert mode

    text input

    to enter insert mode use an insert command - i, I, o, O, a, A, s, S, cc, C

    ESC key exits from insert mode back into command mode

  • Moving around commands

    The majority of commands can be preceded by a digit to govern the number of characters or lines to act upon. This is just the basics.

    h, j, k, l               Left, down, right, up
    H, L, G, g or gg         To top of screen, bottom of screen, end of file,
                             beginning of file
    w, b, 0(zero), $         Forward a word, backwards a word, start of line,
                             end of line
    ^, Ctrl-B, Ctrl-F        First non-whitespace character on line, scroll
                             back/up a screen, scroll forwards/down a screen
    Ctrl-D, Ctrl-U           Scroll forwards, backwards half a window
    Ctrl-J, Ctrl-M           Move cursor down one line in same column, 
                             move to first character on the next line.
    Ctrl-N, Ctrl-P           Move cursor down, up one line in the same column
    Ctrl-H                   Move cursor one space to the left
    %                        Move cursor to the matching parenthesis or brace
    (                        Move cursor to the beginning of a sentence
    )                        Move cursor to the beginning of the next sentence
    {                        Move cursor to the preceding paragraph
    }                        Move cursor to the next paragraph
    |                        Move cursor to the column specified by the count
    +                        Move cursor to the first non-whitespace character in
                             the next line
    -                        Move cursor to the first non-whitespace character in
                             the previous line
    _                        Move cursor to the first non-whitespace character in
                             the current line
    
  • Insert commands

    The majority of commands can be preceded by a digit to govern the number of characters or lines to act upon. This is just the basics.

    i, I                     Cursor position, start of line,
    a, A                     Append at cursor position, at end of line
    o, O                     New line below cursor, before cursor
    s, S                     Delete character - enter insert mode, delete line
                             - enter insert mode
    
  • Replace and delete commands

    The majority of commands can be preceded by a digit to govern the number of characters or lines to act upon. This is just the basics.

    r, R                     Replace character at cursor, start replacing at cursor
    x, X                     Delete character at cursor, delete character to left of cursor
    dd, D                    Delete line, delete from cursor to end of line
    cc, C                    Cut line - enter insert mode, cut from cursor to end of line
                             and insert mode
    
  • Cut and paste commands

    The majority of commands can be preceded by a digit to govern the number of characters or lines to act upon. This is just the basics.

    yy or Y, P, p            Copy current line, paste after cursor, paste before cursor
    

    3Y copies 3 lines from the position of the cursor, move cursor, P pastes the 3 lines at new cursor position.

  • Undo, exit insert mode
    ., u, U, ESC             Repeat last command, undo last command, undo all changes
                             in buffer, exit insert mode
    
  • Some vi command examples
    d3l                  Delete the 3 characters starting at cursor going
                         right/forwards
    5u, 10dd             Undo the last five commands, delete next 10 lines from
                         current position
    c4w, c4b             Cut the next 4 words starting at cursor, cut previous
                         4 words
    ESC:wq               Exit insert mode, write file and quit
    ZZ                   Equivalent of :wq
    :w fred.txt          Write file/buffer out to new file
    :sh                  Start a shell, type 'exit' at shell prompt to return 
                         to editing session
    :n                   Open next file if editing more than one
    :q!                  Quit without saving
    :e 'file1'           Start editing 'file1'
    :e!                  Discard changes to file
    :w >> file1          Append contents of buffer to end of file 'file1'
    :w!                  'Force' write, overwrite contents of current file
    /pattern             Search forwards for pattern
    ?pattern             Search backwards for pattern
    .                    Repeat the last command that changed the file
    ~                    (tilde) Switch case of character