linux vi editor code example

Example 1: linux vi

Use Vim instead of Vi. Vim is easier to use.

Example 2: vi usage

From Command Mode

    e    Move to end of current word
  
    $    Move to end of current line
  
    ^    Move to beginning of current line
  
    +    Move to beginning of next line
  
    -    Move to beginning of previous line

  
    G    Go to last line of the file
  
    :n   Go to line with this number (:10 goes to line 10)

  
    <Ctrl>d   Scroll down one-half screen
  
    <Ctrl>u   Scroll up one-half screen
  
    <Ctrl>f   Scroll forward one full screen
  
    <Ctrl>b   Scroll backward one full screen
  

    )         Move to the next sentence
  
    (         Move to the previous sentence
  
    }         Move to the next paragraph
  
    {         Move to the previous paragraph
 
  
    H         Move to the top line of the screen
  
    M         Move to the middle line of the screen
  
    L         Move to the last line of the screen

  
    %         Move to matching bracket:  ( { [ ] } )