Cheatography
https://cheatography.com
I've been using Vim for a more than a year. This is my collection of intermediate-level features I want to get more comfortable with!
Legend
special keys are surrounded by < > |
e.g.: <CTRL-c> = control-c |
tokens are surrounded by { } |
e.g.: {#} = some number, {id} = some id |
Navigation & Searching
next word |
w
|
previous word |
b
|
end of word |
e
|
forward one screen |
<CTRL-f>
|
back one screen |
<CTRL-b>
|
forward half screen |
<CTRL-d>
|
back half screen |
<CTRL-u>
|
search for word under cursor |
#
|
Files
Always set working directory to current file |
set autochdir
|
File explorer |
:e .
|
OS file explorer |
:browse e
|
name of current file |
:echo @%
|
Search for file in hierarchy and open it |
:tabe **/{file}
|
Set working directory to current file |
:lcd %:p:h
|
Save file with no eol |
:set binary :set noeol
|
|
|
Editing
open new line for insert above cursor |
o
|
open new line for insert below cursor |
O
|
change current word |
cw
|
change entire line |
cc
|
change rest of line |
C
|
replace current character |
r
|
replace all text until <ESC> is typed |
R
|
swap characters |
xp
|
delete forward |
x
|
delete backward |
X
|
delete to the end of the line |
D
|
delete forward one word |
dw
|
deletes # lines |
{#}dd
|
toggle case |
~
|
toggle case of word |
g~iw
|
delete blank lines |
:g/^$/d
|
delete trailing white space |
:%s/\s\+$//
|
delete all extra white space between words |
:s/\s\+/ /g
|
insert chars # times |
<CTRL-o>{#}{chars}<ESC>
|
Selecting & Copying
match braces |
%
|
select all |
gg"+yG
|
copy forward one word |
yw
|
copy from cursor to the end of line |
y$
|
copy # lines |
{#}yy
|
|
|
Tabs and Windows
split window and load another file |
:split {file}
|
move cursor to another window |
<CTRL-w> <CTRL-w>
|
maximize current window |
<CTRL-w>_
|
make all equal size |
<CTRL-w>=
|
close all other windows |
<CTRL-w>o or :only
|
next tab | prev tab |
gt | gT
|
Registers & Buffers
show name and contents of registers |
:reg
|
paste what's in register a |
"{a}p
|
yank selection into register a |
"{a}y
|
record into register a (q again to stop) |
q{a}
|
execute register a |
@{a}
|
repeat last one |
@@
|
List buffers |
:ls or :buffers
|
Display buffer by id |
:b{id}
|
Next and prev buffer |
:bnext and :bprev
|
Delete buffer by id |
:bd{id} (append ! to discard changes)
|
Surround.vim
change surroundings |
cs{from_char}{to_char}
|
delete surroundings |
ds{char}
|
surround word |
ysiw{char}
|
surround line |
yss{char}
|
|
Created By
www.pasz.com
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets