how to use vi linux code example

Example 1: how to use vi editor mac

Type "vi file.txt" at command prompt.
Move cursor to where new text will be added.
Type "i" to change to insert mode.
Type new text.
Type ESC to go back to command mode.
type ":wq" and ENTER to write the file and quit.

Example 2: linux vi

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

Example 3: 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:  ( { [ ] } )