This page is intended to be a manual for quickly finding commands, and a learning note for myself.
Just remember them and prictice them when you are coding.
Prictice makes perfect.
There are four modes in Vim and VScode-vim:
| From | To | Key |
|---|---|---|
| normal | insert | i, a, I, A...(many keys) |
| normal | command | : |
| normal | view | v, V |
| normal | replace | R |
| view, command, insert | normal | ESC |
When using some editing instructions, it will also cause mode conversion.
Vim has fast ways to move cursor without mouse.
| Key | Result | Move Unit |
|---|---|---|
| h | move left by one character | character |
| l | move right by one character | character |
| j | jump to the line below | line |
| k | climb to the line above | line |
| w | jump to the beginning place of next word | word |
| b | jump to the beginning place of last word | word |
| e | jump to the place where the next word ends | word |
| ge | jump to the place where the last word ends | word |
| W | jump to the beginning of the next section separated by space | part without spaces |
| B | jump to the beginning of the privious section separated by space | part without spaces |
| E | jump to the end of the next section separated by space | part without spaces |
| GE | jump to the end of the privious section separated by space | part without spaces |
number(0)$ |
jump to the last character of the next number line |
line |
| ^ | jump to the first character that is not a space of current line | line |
| 0 | jump to the beginning of current line | line |
| G | jump to the last line of text | full text |
| gg | jump to the first line of text | full text |
numberG |
jump to the line whose line number is number |
full text |
| % | jump between left and right brackets | left and right brackets |
fchar |
jump to the next occurrence of char in current line |
occurrence of char in current line |
Fchar |
jump to the last occurrence of char in current line |
occurrence of char in current line |
number% |
jump to the number percent of the full text |
full text |
| H | jump to the top line of current screen | screen |
| L | jump to the last line of current screen | screen |
| M | jump to the middle line of current screen | screen |
| Ctrl+u | move half screen up | screen |
| Ctrl+d | move half screen down | screen |
| Ctrl+e | move one line down | line |
| Ctrl+y | move one line up | line |
| Ctrl+f | move entire screen down | screen |
| Ctrl+b | move entire screen up | screen |
| zz | move the current line to the middle of the screen | screen |
| zt | move the current line to the top of the screen | screen |
| zb | move the current line to the bottom of the screen | screen |
Ctrl+w+w |
move between windows | windows |
Ctrl+w+h |
move to the left window | windows |
Ctrl+w+l |
move to the right window | windows |
Ctrl+w+j |
move to the window below | windows |
Ctrl+w+k |
move to the window above | windows |
| `. | last modified position | full text |
| * | grab the word from under the cursor and search for the next one | full text |
| # | grab the word from under the cursor and search for the privious one | full text |
| gd | jump from the use of a variable to its local declaration | full text |
| [{ | jump back to the "{" at the start of the current code block | code block |
| ]} | jump back to the "}" at the end of the current code block | code block |
mark:mcharreturn:`char |
set a mark at current cursor position, and jump to the mark | full text |
| Key | Result | Modify unit |
|---|---|---|
| x | delete the character under the current cursor | character |
| X | delete the character before the current cursor | character |
| dd | delete current line | line |
| s | delete the character under the current cursor, change to insert mode | character |
| u | undo last modification command | command |
| Ctrl+r | undo last undo | command |
| de | delete the content from the current cursor to the end of current word | word |
| p | paste copied content behind the current cursor | |
| P | paster copied content before the current cursor | |
| y | copy selected content under view mode | |
| yy | copy the current line | line |
| Y | copy the current line | line |
| yaw | copy the current word | word |
| daw | delete the current word | word |
| ye | copy the content from the current cursor to the end of current word | word |
| o | insert a new line below the current line and switch to insert mode | line |
| O | insert a new line above the current line and switch to insert mode | line |
| cw | change the current word | word |
| . | repeat the last change at the current cursor position | command |
record start:qcharrecord end:qrepeat:@char |
record commands into a register with name char, and repeat it |
command |
rchar |
replace the character under the cursor with char |
character |
| R | replace characters with characters to be typed without switch to insert mode | character |
| Key | Result | Search Order |
|---|---|---|
/target |
search target in this file |
beginning to ending |
| * | grab the word from under the cursor and search for the next one | beginning to ending |
| # | grab the word from under the cursor and search for the privious one | ending to beginning |
| n | move to the next search result | same to the search command |
| N | move to the last search result | opposite to the search command |
| Key | Result |
|---|---|
| :wq | write and quit |
| :q | only quit |
| :q! | reset all changes and quit |
| :w | write |
| ZZ | write and quit |
:set numberor:set nonumber |
whether set line number |
:set ignorecaseor:set noignorecase |
whether distinguish uppercase and lowercase when searching |
:set hlsearchor:set nohlsearch |
whether highlight all matching results when searching |
:set incsearchor:set noincsearch |
whether highlight current matching result in a difference way |
:set wrapscanor:set wrapscan |
whether to loop through among the search results |
:edit filepath |
open the file with path: filepath |
| :split | open another window horizontally |
| :vsplit | open another window vertically |
| :only | write and quit other opened files |
| :qall | quit all opened files |
| :wqall | write and quit all opened files |
| Key | Result |
|---|---|
| Ctrl+g | check the current file and current cursor position |