Based on my most used command when doing daily text/code editing.
Normal Mode
gg: move the cursor to the beginning of the filei: enterinsertmodex: Cut characterdw: Cut worddd: Cut full lineyw: Copy wordyy: Copy full linep: Paste:1: Go to line number 1:w: Write the filei.e save:q: Quit:q!: Quite without saving:wq: Write and quit
Insert Mode
esc: back tonormalmode
Use Cases
- Select entire file in visual mode.
- Steps:
- ensure we are in
normalmode - Move the cursor to the beginning of the file using
gg - Enter visual line mode by pressing
V - Move to the end of the file by pressing
G, which selects all content from the start to the end of the file
- Key sequence:
ggVG - delete multiple lines that contains a word:
:g/word/d - Replace word in specific line ranges:
:10,20s/old-word/new-word/g⇒ from line10to line20:,$s/old-word/new-word/g⇒ current line to end of line:1,.s/old-word/new-word/g⇒ first line to current line