
149

Vim cheatsheet
source link: https://devhints.io/vim
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Exiting
:qa |
Close all files |
:qa! |
Close all files, abandon changes |
:w |
Save |
:wq / :x |
Save and close file |
:q |
Close file |
:q! |
Close file, abandon changes |
ZZ |
Save and quit |
ZQ |
Quit without checking changes |
Navigating
h j k l |
Arrow keys |
<C-U> / <C-D> |
Half-page up/down |
<C-B> / <C-F> |
Page up/down |
Words
b / w |
Previous/next word |
ge / e |
Previous/next end of word |
0 (zero) |
Start of line |
^ |
Start of line (after whitespace) |
$ |
End of line |
Character
fc |
Go forward to character c |
Fc |
Go backward to character c |
Document
gg |
First line |
G |
Last line |
:n |
Go to line n |
nG |
Go to line n |
Window
zz |
Center this line |
zt |
Top this line |
zb |
Bottom this line |
H |
Move to top of screen |
M |
Move to middle of screen |
L |
Move to bottom of screen |
Search
n |
Next matching search pattern |
N |
Previous match |
* |
Next whole word under cursor |
# |
Previous whole word under cursor |
Tab pages
:tabedit [file] |
Edit file in a new tab |
:tabfind [file] |
Open file if exists in new tab |
:tabclose |
Close current tab |
:tabs |
List all tabs |
:tabfirst |
Go to first tab |
:tablast |
Go to last tab |
:tabn |
Go to next tab |
:tabp |
Go to previous tab |
Editing
a |
Append |
A |
Append from end of line |
i |
Insert |
o |
Next line |
O |
Previous line |
s |
Delete char and insert |
S |
Delete line and insert |
C |
Delete until end of line and insert |
r |
Replace one character |
R |
Enter Replace mode |
u |
Undo changes |
<C-R> |
Redo changes |
Exiting insert mode
Esc / <C-[> |
Exit insert mode |
<C-C> |
Exit insert mode, and abort current command |
Clipboard
x |
Delete character |
dd |
Delete line (Cut) |
yy |
Yank line (Copy) |
p |
Paste |
P |
Paste before |
"*p / "+p |
Paste from system clipboard |
"*y / "+y |
Paste to system clipboard |
Visual mode
v |
Enter visual mode |
V |
Enter visual line mode |
<C-V> |
Enter visual block mode |
In visual mode
d / x |
Delete selection |
s |
Replace selection |
y |
Yank selection (Copy) |
See Operators for other things you can do.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK