# Vim
Just for simple editing, otherwise why not use VS Code 😉
Press . to repeat last change,给多行加 / 去注释的时候很实用
# Moving cursor
| Key | Operation |
|---|---|
| gg | go to start of the file |
| G | go to end of the file |
| 0/Home | go to first char in the line |
| ^ | go to first non-blank char in the line |
| $/End | go to last char in the line (just like in RegExp) |
| Ctrl+f/d | next page/half page |
| Ctrl+b/u | previous page/half page |
| w | next word (dw delete current word) |
| b | previous word |
| f{char} | jump to next {char} (on this line) |
; repeat last f (or F/t/T) operation
# Copy and paste
| Key | Operation |
|---|---|
| yy | copy the line (mnemonic: yank) |
| dd | delete the line (behaves like a cut operation) |
| p | paste after the current line |
| P | paste before the current line |
| dt{char} | delete up to this {char} (excluding) on this line |
yj copy 2 lines, y2k copy 3 lines (which includes 2 lines above)
df{char} ~ (including)
# Replace/Overtype
| Key | Operation |
|---|---|
| r | replace current char (in-place) |
| cw | replace current word (delete current word and enter insert mode) |
| R | enter replace mode |
x delete current char
# Search
| Key | Operation |
|---|---|
| / | enter search mode, type your search string, press Enter to confirm or ESC to cancel |
| n/N | go to next/previous occurrence (similar to F3/Shift+F3 in most IDEs) |
Type :noh to turn off highlighting until the next search
# More
Vim online documentation (opens new window)