Tuesday, February 12, 2013

VIM Quick Command Tutorial #1

There are 3 basic modes in VIM.
a) <Esc> - Normal
b) i - Insert
c) v - Visual
1. Opening Vim
 vim            - open
 vim [filename] - open a file

2. Quit, and save
 :q! - quit without saving
 :q - quit
 :w - write
 :wq or :x - write and quit

3. Cursor moving
  k       up
 h l  left right
  j      down

 ^ - content beginning of the line
 $ - end of line
 w - move by a word
 b - move backward by a ward
 gg - go to the head of the file
 <shift>+g - go to the end of the file
 :number - to line number of 

 { - previous paragraph
 } - next paragraph

4. Editing feature
 i - insert before the cursor
 a - append after the cursor
 o - new line below
 O - new line above

5. Copy(Yank), paste, and delete
 yy - copy the whole line
 yw - copy the word
 y^ - copy to the beginning of line from cursor position
 y$ - copy to the end of the line from cursor position

 p - paste
 np - where n represents number of times to paste

 dd - delete the current line
 dw - delete the current word
 d^ - delete to the beginning of the line from cursor position
 d$ - delete to the end of the line from cursor position

6. Visual mode
 v - select within line
 V - select lines

7. Formating
 < - shift back  > - shift forward
 == auto indent

8. Repeating
 . - repeats the previous command

No comments:

Post a Comment