Vim Editor 101
How to quit vim? - -!
It has Dual-mode
- GUI
- Editor
GUI Mode
move
- “H” moves left;
- “K” moves up;
- “L” moves right;
- “J” moves down.
Copy & Paste
- “Y” copies a line of text to the buffer.
- “yy” copies a whole line of text.
- “P” pastes it to the cursor’s current position.
- “D” delete whole line and buffer
- “dd” delete whole line and buffer
- “xN”+ enter, will do
- ”:” go to specific line: “:13”
- Search and text replace: “:%s/Jack/John/g”
- ”/” find, like “/moss”
- “u” for undo last command
- “:w” save
- “:wq” save and quit
- “:q!” quit without save
Editor Mode
- “i” to begin inserting text at the current cursor position
- “a” to begin inserting after the current cursor position
- o
escape
to quit editor mode
Settings
find settings at ~/.vimrc
- “:syntax on” color theme
- “colorscheme “+ tag, to change theme
- “vim ftp:////". For example: “vim ftp://172.16.15.73//Users/john/test.pl"
Use cases
Empty a file
- Go to command mode in the editor by pressing
ESC
key on the keyboard. - Press
gg
. It will take to the first line of the file. - Then press
dG
. This will delete from the first line to the last line.