0% found this document useful (0 votes)
41 views

VI / Vim Graphical Cheat Sheet: I I O o A A S S R

This document is a cheat sheet for the vi/vim text editor. It provides a breakdown of normal mode, ex mode, and visual mode commands in a table format organized by key. The commands covered include navigation, editing, searching, and more.

Uploaded by

Tobias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

VI / Vim Graphical Cheat Sheet: I I O o A A S S R

This document is a cheat sheet for the vi/vim text editor. It provides a breakdown of normal mode, ex mode, and visual mode commands in a table format organized by key. The commands covered include navigation, editing, searching, and more.

Uploaded by

Tobias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

version 1.

1
April 1st, 06

Esc vi / vim graphical cheat sheet


normal
mode

~ toggle
case ! @· #
external
filter $
play
macro % prev
ident^ & *
eol
( )
goto
match
"soft"
bol
repeat
:s
next
ident
begin
sentence
end
sentence _"soft" bol
down + next
line


goto
mark 1 2 2 3 4 5 6 7 8 9 0 "hard"
bol - prev
line = auto 3
format

Q ex
modeW E WORDR
next
T· end
WORD Y U I
replace
mode O P
back
'till
yank
line
undo
line
insert
at bol
open
above
paste
before { begin
parag. } end
parag.

q· w
record
macro e r·
next
word t· end
wordy 1,3
u i
replace
char o p'till yank undo
insert
mode
open
below
paste
after
1
[· misc
]· misc

A S
append
at eol D F·
subst
line G H
delete
to eol J K"back"
L
find ch : eof/
goto ln
screen
top
join
lines
help screen
bottom
ex cmd
line "· reg. 1
spec | goto
bol/
col

a s
append
d
1,3

subst
char g· 6 hdelete j kfind
char l ; extra
cmds
repeat
t/T/f/F '· goto
mk. bol \· used!
not

Z· ?·
4 3 3
Xquit
C 1,3 V back-
space B Nchange
M
to eol < >
visual
lines
prev
WORD
prev
(find)
screen
mid'l
un-
indent indent
find
(rev.)

z· 5
xextra
cmds c v
delete
char b nchangem· , .
visual
mode
prev
word
next
(find)
set
mark
reverse
t/T/f/F
repeat
cmd /· find

moves the cursor, or defines Main command line commands ('ex'): Notes:
motion the range for an operator :w (save), :q (quit), :q! (quit w/o saving) (1) use "x before a yank/paste/del command
:e f (open file f), to use that register ('clipboard') (x=a..z,*)
command direct action command, :%s/x/y/g (replace 'x' by 'y' filewide), (e.g.: "ay$ to copy rest of line to reg 'a')
if red, it enters insert mode
:h (help in vim), :new (new file in vim),
requires a motion afterwards, (2) type in a number before any action
operator operates between cursor & to repeat it that number of times
Other important commands:
destination CTRL-R: redo (vim), (e.g.: 2p, d2w, 5i, d4j)
special functions, CTRL-F/-B: page up/down, (3) duplicate operator to act on current line
extra requires extra input CTRL-E/-Y: scroll line up/down, (dd = delete line, >> = indent line)
q· commands with a dot need
a char argument afterwards
CTRL-V: block-visual mode (vim only)
Visual mode:
(4) ZZ to save & quit, ZQ to quit w/o saving
bol = beginning of line, eol = end of line, Move around and type operator to act (5) zt: scroll cursor to top,
mk = mark, yank = copy on selected region (vim only) zb: bottom, zz: center
words: quux(foo, bar, baz); (6) gg: top of file (vim only),
gf: open file under cursor (vim only)
WORDs: quux(foo, bar, baz);

For a graphical vi/vim tutorial & more tips, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
version 1.1 moves the cursor, or defines
motion
April 1st, 06
vi/vim lesson 1 - basic editing the range for an operator
command direct action command,
if red , it enters insert mode

Esc
normal
mode

$ eol
^ "soft"
bol

0 "hard"
bol

W next
WORD E end
WORD R replace
mode

w next
word e end
word u undo
i insert
mode

A append
at eol : ex cmd
line

h j k l
X back-
space B prev
WORD

x delete
char b prev
word

Basics: Extras:
h j k l are vi/vim cursor keys – use them as they are much u to undo the last action – traditional vi has a single level, while vim
closer than regular cursor keys! supports unlimited undo (CTRL - R to redo)
Use i to enter insert mode, cursor turns from a block into a vertical 0
jumps directly to the beginning of the line, $ to the end,
line, and you can type in text. Use Esc to return to normal mode. and ^ to the first non-blank
Use x to delete the current character, or X to delete the one to Use w b e to move along ‘words’. A ‘word’ is a sequence of all
the left alphanumeric or punctuation signs: quux(foo, bar, baz);
Use A to go insert text at the end of the line (wherever you are Use W B E to move along WORDs. A 'WORD' is a sequence of
in the line!) any non-blank characters: quux(foo, bar, baz);
(Note: insert mode is actually very similar to a regular editor, you can use
Use R to enter insert mode with an overstrike cursor, which
cursor/navigation keys, backspace, delete…)
types over existing characters.
: w and press enter to save, : q and enter to quit.

For the rest of the tutorial & a full cheat sheet, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
version 1.1 Learned
learned learned in previous
April 1st, 06
vi/vim lesson
vi / vim 2 - operators
II - operators && repetition
repetition motion
lessons
moves the cursor, or defines
the range for an operator
command direct action command,
if red , it enters insert mode

Esc operator requires a motion afterwards,


operates between cursor &
destination
normal
mode

$ eol
^ "soft"
bol

1 2
2 3 4 5 6 7 8 9 0 "hard"
bol

W next
WORD E end
WORD R replace
mode T· back
'till

w next
word e end
word t· 'till u undo
i insert
mode

A
append
at eol F· "back"
find
fwdch : ex cmd
line

d delete
f· find
fwd
tochar
char h j k l
X back-
space V visual
lines B prev
WORD

x delete
char c change v visual
mode b prev
word . repeat
cmd

Basics: Extras:
f , followed by another key, moves the cursor to the next instance Prepend a count to any command/motion to repeat it that number
of that character on the current line, F does the same backwards. of times:
d 2 w to delete up to the second word.
t and T do the same, but they stop right before the character.
d 2 t 2, to delete up to but not including the second comma.
d (delete), followed, by any motion deletes the text between the 2 i repeats the text after you press (Esc) to finish the input session.
cursor and that motion’s destination d w t , d f - …).
Repeat operator ( c c or d d ) to operate on the current line.
c (change) does the same, but leaves you in insert mode.
Only in vim, v enters visual mode. Move around with motions, the
Some motions, such as j and k , are linewise – deletion includes text will be highlighted. Press an operator to operate on that selection.
the full start/end lines.
V enters visual-lines mode – like v , but selecting whole lines.
. repeats the last editing action: text input, delete or change, etc…
motion is recalculated at the new place. CTRL - v selects rectangular blocks.

For the rest of the tutorial & a full cheat sheet, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
Learned
learned learned in previous
version 1.1
April 1st, 06 vi/vim lesson 3 - yank & paste lessons
motion moves the cursor, or defines
the range for an operator
command direct action command,
if red , it enters insert mode

Esc operator requires a motion afterwards,

extra
operates between cursor &
destination
special functions,
normal requires extra input
mode

$ eol
^ "soft"
bol

1 2
2 3 4 5 6 7 8 9 0 "hard"
bol

W next
WORD E end
WORD R replace
mode T· back
'till O open
above P paste
before

w next
word e end
word t· 'till y yank u undo
i insert
mode o open
below p paste
after

A
append
at eol F· "back"
find ch : ex cmd
line "· reg.
spec

f· j k
1,3
d delete find
char h l
X back-
space V visual
lines B prev
WORD

x c 1,3 v
delete
char change
visual
mode b prev
word . repeat
cmd

Basics Extras
Use y followed by any motion to ‘yank’ (copy). 2
(“)
" and an a2
" - z" character before any yank/delete/paste command
2
chooses a register.
Use p
v to paste after (if charwise, to the right, if linewise, below).
An A2 2
" - Z
" register before yank/delete means “append-copy”.
v to paste before.
Use P
2
" 2
"* or 2 2 select the system clipboard.
" +
y y copies the current line.
y also works in visual mode.
v enters insert mode in a new empty line below the current one.
0
Text deleted with d , c , x
v … is also copied!
v does the same above the current line.
O

For the rest of the tutorial & a full cheat sheet, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
learned in previous
version 1.1 Learned
learned
April 1st, 06 vi/vim lesson 4 - searching lessons
motion moves the cursor, or defines
the range for an operator
command direct action command,
if red , it enters insert mode

Esc operator requires a motion afterwards,


operates between cursor &
destination
special functions,
normal extra
requires extra input
mode

# prev
ident $ eol
^ "soft"
bol * next
ident

1 2
2 3 4 5 6 7 8 9 0 "hard"
bol

W E next
WORD
end
WORD R replace
mode T· back
'till O open
above P paste
before

w e next
word
end
word t· 'till y yank u undo
i insert
mode o open
below p paste 1
after

A
append
at eol F· "back"
find ch : ex cmd
line "· reg. 1
spec

f· j k
1,3
d delete find
char h l
X back-
space V visual
lines B prev
WORD N prev
(find) ?· find
(rev.)

x c 1,3 v
delete
char change
visual
mode b prev
word n next
(find) . repeat
cmd /· find

Basics: Extras:
/ is the basic search motion – type the text you are searching for
k The following very useful motions work only in vim:
after the slash, and then press return. Being a motion, you can use k
* searches forward for the next instance of the identifier under
this after an operator, or in visual mode. the cursor.
? does the same, backwards.
k k does the same backwards.
#

k repeats the last search in the same direction, N


n k repeats it in
the reverse direction
Be careful, because the search target is interpreted as a regular
expression: a*b means zero or more ‘a’s followed by a ‘b’, ^abc
means ‘abc’ at the beginning of a line, [0-9] looks for the next
digit, etc…

For the rest of the tutorial & a full cheat sheet, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
Learned
learned learned in previous
version 1.1 lessons
April 1st, 06
vi/vim lesson 5 - marks & macros motion moves the cursor, or defines
the range for an operator
command direct action command,
if red , it enters insert mode
requires a motion afterwards,

Esc
operator
operates between cursor &
destination
extra special functions,
normal requires extra input
mode

@· # play
macro
prev
ident $ eol
^ "soft"
bol * next
ident

`· 1 2 2 3 4 5 6 7 8 9 0
goto "hard"
mark bol

W E next
WORD
end
WORD R replace
mode T· back
'till O open
above P paste
before

q· w
record
macro e next
word
end
word t· 'till y yank u undo
i insert
mode o open
below p paste1
after

Aappend
at eol F· "back"
find ch : ex cmd
line "· reg. 1
spec

f· j k '·
1,3
d delete find
char h l goto
mk. bol

X back-
space V visual
lines B prev
WORD N prev
(find) ?· find
(rev.)

x c 1,3 v
delete
char change
visual
mode b prev
word n next
(find) m· set
mark . repeat
cmd /· find

Marks: Macros:
v followed by an a
Use m v - z
v character to set a mark. Use q v - z
v followed by an a v character to start recording.
Use v
v̀ followed by a character to go to that mark. Use qv afterwards to stop recording.
Use v' and a character to go to the first non-blank in that line. @
v followed by a character replays that macro.
v - Z
A v marks are global, a
v - z
v per-buffer. @
v @
v to repeat the last macro played.
v̀ . refers to the position of the last modification.
v

For the rest of the tutorial & a full cheat sheet, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
learned in previous
version 1.1 Learned
learned
April 1st, 06 vi/vim lesson 6 – various motions lessons
motion moves the cursor, or defines
the range for an operator
command direct action command,
if red , it enters insert mode

Esc operator requires a motion afterwards,


operates between cursor &
destination
special functions,
normal extra
requires extra input
mode

@· # play
macro
prev
ident % $ ^ eol
* goto
match
"soft"
bol
next
ident ( )
begin
sentence
end
sentence+ next
line


goto
mark 1 2 2 3 5 4 6 7 8 9 0 - "hard"
bol
prev
line

W E next
WORD
end
WORD T·R replace
mode
back
'till O P
open
above { }
paste
before
begin
parag.
end
parag.

q· w
record
macro e next
word
end
word t· y u i 'till yank undo
insert
mode o p
open
below
1
[· ]·
paste
after
misc misc

Aappend
at eol F· G H "back"
find ch K eof/
goto ln
screen
top
help
L :
screen
bottom "· 1ex cmd
line
reg.
spec

f· j k '·
1,3
d delete
h find
char l goto
mk. bol

X back-
space V B N Mvisual
lines
prev
WORD
prev
(find)
screen
mid'l ?· find
(rev.)

x c 1,3
delete
char v b
change n m·
visual
mode
prev
word
next
(find)
set
mark . /·
repeat
cmd
find

% jumps between matching pairs of ‘(‘ ‘)’, ‘[‘, ‘]’, etc… ( and ) jump to the beginning/end of the current sentence.

H M L jump directly to the top/middle/bottom of the screen. { and } jump to the previous/next empty line.

G jumps to the end of the file, or to the line # typed before it. [ [ jumps to the previous '{' in column 0.

- / + jump to the previous/next line.


G ] ] jumps to the next '{' in column 0.

K , not technically a motion, jumps to the help for the word under
the cursor: vim help, man page under unix, etc...

For the rest of the tutorial & a full cheat sheet, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
learned in previous
version 1.1 Learned
learned
April 1st, 06 vi/vim lesson 7 - various commands lessons
motion moves the cursor, or defines
the range for an operator
command direct action command,
if red , it enters insert mode

Esc operator requires a motion afterwards,

extra
operates between cursor &
destination
special functions,
normal requires extra input
mode

~ toggle
case @· # play
macro$ %
prev
ident ^ eol
* ( goto
match ) "soft"
bol
next
ident
begin
sentence
end
sentence + next
line


goto
mark 1 2
2 3 4 5 6 7 8 9 0 "hard"
bol - prev
line = auto
format

W E WORDR
next

end
WORD Y replace
mode O back
P
'till
yank
line
open
above
paste
before { begin
parag. } end
parag.

q· w
record
macro e next
word r· t·
end
word y u i
replace
char o p
'till yank undo
insert
mode
open
below
paste1
after [· misc
]· misc

A S
append
at eol D subst
lineF· G H
delete
to eol J K
"back"
find ch L :
eof/
goto ln
screen
top
join
lines
help screen
bottom
ex cmd
line "· reg. 1
spec

s f· j k '·
1,3
d subst
char h
delete find
char l goto
mk. bol

X C V
back-
space B N
change
to eol M <
visual
lines > prev
WORD
prev
(find)
screen
mid'l
un-
indent indent
?· find
(rev.)

x c 1,3 vdelete
char b n
change m· visual
mode . prev
word
next
(find)
set
mark
repeat
cmd /· find

Basics: Extras:
v joins the current line with the next one, or all the lines in the
J v and a motion to indent one or more lines.
>
current visual selection.
v and a motion to unindent.
<
vr followed by any character replaces the current character with
that one. v and a motion to reformat a range of text.
=

v is shorthand for c
C v $
v , changes to end of line. v >
All of them work in visual mode, or can be repeated ( > v , etc… )
to operate on the current line.
v is shorthand for d
D v , deletes to end of line.
v $
~
v toggles the case of the character under the cursor.
v is shorthand for v
Y y , yanks the whole line.
y v
v
s deletes the character under the cursor and enters insert mode. Now go grab the full cheat sheet and learn the rest.
v clears the current line and enters insert mode.
S Start with v a v, and v; . Piece of cake!
I v

For the rest of the tutorial & a full cheat sheet, go to www.viemu.com home of ViEmu, vi/vim emulation for Microsoft Visual Studio

You might also like