Show Menu

Intermediate Vim Cheat Sheet by

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!
unix     vi     vim     text     editors

Legend

special keys are surrounded by < >
e.g.: <C­TRL­-c> = control-c
tokens are surrounded by { }
e.g.: {#} = some number, {id} = some id
Follow me on twitter: @pasztech

Navigation & Searching

next word
w
previous word
b
end of word
e
forward one screen
<C­TRL­-f>
back one screen
<C­TRL­-b>
forward half screen
<C­TRL­-d>
back half screen
<C­TRL­-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 <ES­C> 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
<C­TRL­-o>­{#}­{ch­ars­}<E­SC>

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
<C­TRL­-w> <CT­RL-­w>
maximize current window
<C­TRL­-w>_
make all equal size
<C­TRL­-w>=
close all other windows
<C­TRL­-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)

Surrou­nd.vim

change surrou­ndings
cs{fr­om_­cha­r}{­to_­char}
delete surrou­ndings
ds{char}
surround word
ysiw{­char}
surround line
yss{c­har}

Download the Intermediate Vim Cheat Sheet

2 Pages
//media.cheatography.com/storage/thumb/adampasz_intermediate-vim.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          VI Editor Cheat Sheet
          Vim Cheat Sheet