vi / vim editor usage

1. The operation in the normal mode:

(1) h (or the left arrow key) cursor one character
            j (or down arrow keys) cursor down one character
           k (or upward direction key) on the cursor one character
           L (or the right arrow key) Cursor right one character

(2) [Ctrl] + f a downward movement of the screen (corresponding to the Page Down key)
         [the Ctrl] + B an upward movement of the screen (corresponding to the Page Up key)

(3) dd delete an entire cursor line

        ndd Delete n lines down cursor

        yy line where the cursor is copied
       nyy copy cursor down n rows

(4) u undo the last operation

 

2. The normal mode is switched to the editing mode:

 

(1) Insert:

         a inserted starting from a character at the current cursor
         A inserted starting from the last character of the line cursor
         o English lowercase letters o, insert a new row at the next row of the current row of the cursor and start insert
        O capital letters O, insert a new row at the current cursor line at the line and start insert

(2) replacement mode:

         r will replace it once a character under the cursor    
         R will always replace the cursor character until you press [ESC] key
         [ESC] to exit edit mode back to normal mode

 

3. The normal mode is switched to the command line:

   : w to save the file
   :! w If the file is read-only, forced to save the file
   : q leave vi
   : q forced to leave without saving vi!
   : wq save after leaving the
   :! wq after leaving compulsory saving

   : set nu show line numbers
   : set nonu cancel the display line number
   : w newfile Save As

 

4. Select the block (normal mode use):

   v, V v: where the highlight cursor is over the selected; V: row selection cursor highlight elapsed
   [Ctrl] + v block selection, the available rectangular select text
   copy the highlighted where y to the clipboard
   d. highlight of content removal

 

5. Multi-file editing:

   vim file1 file2 open two files
   : n edit a file
   : N edit a file
   : files lists all files currently opened with vim

 

Guess you like

Origin www.cnblogs.com/zhaihuijie/p/11730029.html