Editor - Vim
Mode
- command mode
- type
i-> insert mode - type
:-> last-line mode
- type
- insert mode
- click
Esc-> command mode
- click
- last-line mode
Navigation
- in command mode
Gmoves to the last line.ggmoves to the first line.0moves to beginning of line.$moves to end of line.
- in command mode
- 上下左右:
- use arrow key
k,j,h,l
- 翻页上:
PGUPCtrl+B
- 翻页下:
PGDNCtrl+F
- 上下左右:
Editing
- in command mode
dwwill delete a character.ddwill delete a line.uwill undo the last operation.Ctrl-rwill redo the last undo.
Copy and Paste
- in command mode
vhighlight one character at a time.ycopy textdcut textppaste text"+ycopy to system clipboard.
refer to https://vim.fandom.com/wiki/Copy,_cut_and_paste
Search
- in command mode
/<String>search for Stringngo to next matching patternNgo to previous matching pattern
- set search highlight color
:set hlsearch:nohlsearch
- show line number
:set number
Saving and Quiting
- in last line mode
:wfor saving:w filenamefor saving to another file:qfor quit
- in command mode
ZZfor saving and quit
Re-format a long line
- First set your vim so that it understands that you want 80 characters:
:set tw=80 - then, hilight the line:
V - and make vim reformat it:
gq