Show Menu

VIM IDE Cheat Sheet by

vim IDE key mapping
ide     vim

Beginner Block

start insert
escape to normal mode
in normal mode, write to current file
in normal mode, quit the editor
[ https:­//g­ith­ub.c­om­/Pi­pin­g/d­otfiles ] has my config­ura­tion
Notation: <l­e­a­de­­r>m means <s­pac­e>m
<C­-a> means Ctrl + A , <S­-x> means Shift + x

Motions: command that moves the cursor

search and move to next typed character
similar to f/F. but stop before character
start/end of current line
next start/end of word, W/E for word with punctu­nation
previous start of word B for word with punctu­ation
go to line {count}, default first line
go to line {count}, default last line
previo­us/next start of the line
cursor go to TOP/MI­DDL­E/B­OTTOM of the screen
(single quote twice) previous location in jumplist
previous marked position using m{a-z}, E.g. ma `a
To the position where the last change was made.
move to closing pair [], {}, ()
a number type before motions, repeat {count} motion
:help motion
check more on documents inside vim
Vim Concept: Motions - command that moves the cursor, depends on current cursor position. Above list is not complete! It can be used with OPERATOR to effici­ently editing text in Textual User Interf­ace


around a paragraph
inner word
aroud word
inner double quote
around double quote
last search result, follow after operator
search­-offset to that whole line
:h iw
help for more

Operator - editing the text effici­ently

reverse case
filter with external program, E.g. format doc
make lower/­upper case
indent left/right
filter with predefined equalprg
fold the text
Two way to combine operator and select­ions:
1. <op­era­tor­><m­oti­on> or <op­era­tor­><t­ext­-ob­jec­t-m­oti­on> etc.
2. <se­lection from visual mode><­ope­rat­or>
E.g. di" delete the word inside double quotes
Press one operator twice operate on current line as the select­ion
E.g. yy copy the current line, dd cut/delete the current line

Paste && Registers

paste content from register " before current cursor
paste after cursor
paste 0 register's content in normal mode
double quote, insert text as if typed
insert­-mode "0p
eval expression after = and paste
the last search pattern
equivalent to p in normal mode
:h i_ctrl-r
more registers
VIM Concept: Registers, used to store copy/cut text, the register can have single character names, {0-9a­-z"%­#*+­:.-=}.

p/P is used in normal mode, other Ctrl-­R{r­egi­ster} are used in insert mode and command line mode. (I reversed p/P since I feel p before cursor is more natural for modern IDE)

Page Movement

move buffer down/up and keep cursor position
bring current line and cursor to center
move current line and cursor to bottom screen
move current line and cursor to top screen

Visual Mode Commands

switch between two ends of selection (anchor)
switch to visual block mode
switch to visual line mode
switch to visual mode
alignment, using plugin easy-­align


go to next tab
go to previous tab
new tab, <­lea­der­>t
close current tab

Frequent Used Custom Shortcuts

[<s­pac­e> and ]<s­pac­e>
add newline before­/after current line
[e and ]e
move current line up/down, count applies
[p and ]p
go for next/p­revious quickfix item
[l and ]l
l for L, next linter hint (ALE Lint)

Target.vim - Extended and Smart Text Object

Key Sequence: <op­era­tor> <sc­ope> <se­ek?> <te­xt-­obj­ect>
a i A I
<sc­ope> around, inner, around­/Inner space included
<se­ek> next text-o­bject
<se­ek> seek last text-o­bject
, . ; : ...
<text object> for separator
b ( )
<text object> for parent­heses()
<text object> blocks, html tags
Usage: <op­era­tor> <sc­ope> [<s­eek­>] <te­xt-­obj­ect>
- diw delete the word without the surrou­nding whitespace
- vaw visual select the word & surrou­nding whitespace
- cia change next function arguments ( target.vim )
- dinb delete content inside next parent­hesis (targe­t.vim)

Vim Diff Mode

:diffsplit [filename]
split the window with diff mode on
turn off diff mode, (include diff highli­ghts)
:set diff!
switch the diff color highlight only
windo diffoff can turn off all diffmode windows in current tab

Windows (Split, Size Adjust­ment, Placement)

equal size display all panels
horizontal split
vertical split
go to last accessed window
put pane to absolute left, take full height
put pane to absolute right, take full height
put pane to absolute bottom, take full width
put pane to absolute top, take full width
:set splitright
for vertical split, place new pane right
move to relative left/d­own­/up­/right pane

Insert Mode ( Emacs Style Single Line Editing)

Jump to the beginning of the line
Jump to the end of the line
Backwa­rd-­Delete Word
Forwar­d-D­elete Word
backward move cursor one word
forward move cursor one word
delete/cut current line
paste/yank to current line
delete the rest line after cursor

Useful Utility Commands (Normal Mode)

dot command, repeat last change
Join the line below to current line
add {count} to number under cusor
subtract {count} to number under cusor
calculator <C-­R>=­128/2, insert mode
repeat last cmdline command, <le­ade­r>:
break current line and move trailing part one line above
dot command . does not repeat command line commands, only changes that is defined by vim. E.g. invoked by operator c and followup inserted text.

CSCOPE MAPPING (My Config­ura­tion)

:cs add <path to cscope.ou­t> <path to worksa­pce>
add cscope.out <wo­rksapce path>
search assignment to this variable
search the C symbol under cursor
search global defintion
search who called this function
search this string
search for files include the current file
search for files include the filename under cursor

Normal Commands (My Config­ura­tion)

go to pairs, if/else, html tags, etc
format and intent the file E.g. clang-­format
go to end of line
close current window
go to file under cursor or fzf search
toggle invisible characters E.g. whitespace
open tagbar for current file
Remove Highlights :noh
open the undotree
Distra­cti­on-Free Display, full-z­oomed window
open quickfix window

Command Mode :

{range}, equal to 1,$ (the entire file)
:! <ex­ternal cmd>
range of text is being pipe to cmd to be replaced
:%! xxd
edit binary file
:%! xxd -r
save the file into binary form
open cmdline editing windows

fuzzy-­sea­rch­-panel (My config­uration FZF Plugin)

select all
deselect all
select­-de­select current line
open file in new tab
split horizo­ntaly
split vertically

Special and Very Useful Windows -- Quickfix

open/close Quickfix
go to next fix
go to previous fix
Quickfix typically used after :make command and cscope, the quickfix window contains the parsed result from :make that contains where compli­cation error happen, and put cursor to exactly the file/l­ine­/column so user can just fix it!
I open quick fix with my shortcut and prefix a :botright copen to open it at the bottom of window

Commentary ( External Plugin Default)

commen­t/u­nco­mment current line
comment next 10 lines
comment block
comment the paragrah
comment selection (visual mode)

Code Folding

fold selection text
open selection text

Code Review

diffmode for two files (vim -d file1 file2)
git dt
use vim to code review
git dt master
code review based on master branch
modify another buffer to be same as current buffer
modify current buffer to be same as other
! Assuming using GIT for version control, setup the ~/.git­config
d = diff
ds = !git diff --stat
dn = !git diff --name­-only
dt = difftool
tool = vimdiff
prompt = false

Download the VIM IDE Cheat Sheet

4 Pages

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!



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

          Sublime Text 2 Windows Keyboard Shortcuts
          Vim NERDTree Cheat Sheet