Professional Documents
Culture Documents
99
Normal
Vim 7.3+
:version
Sept. 9, 2011
HOW-TO make Vim not suck Out of the Box: :help statusline :set nocompatible ruler laststatus=2 showcmd showmode number
~ toggle case
` goto mark
13
Legend:
Macro
Op
Cmd
Ins
Move
Find
tag
Code
Extra
Modes
n
i
v
o
c
word
play
macro
prev
identifier
ex mode
WORD
record
macro
word
incr. #
10
scroll line
end
WORD
end
word
subst line
del
subst char
del
7,11
decr. #
:suspend
quit
extra
4
5
0
2
Ctrl 4
Ctrl 5
goto
match
4
12
Ctrl ^
5
:redo
10
6
ctags return
scroll line
T until char Y
copy line
replace
char
copy
until char
page
file/cursor info
F find char G
goto eof /
goto line#
find char
Normal / Cancel
block select
select
lines
select
chars
del char
change
del char
change
0
2
extra
page
0
2
Ctrl 8
Ctrl 9
Ctrl 0
repeat :s
next
identifier
begin
sentence
end
sentence
(
8
8
half page
undo
paste
15
word
open
redraw
Bottom
screen
Ctrl J
Join lines
15
Ctrl M
Ctrl ,
Middle
screen
<
undent
set mark
"prev"
f/F/t/T
16
>
.
indent
repeat
cmd
Ctrl /
2
find
find
16
autoformat
Normal
paragraph
paragraph
misc.
misc.
ctags identifier
Ctrl '
Ex cmd line
"next"
f/F/t/T
Ctrl =
cur line
Ctrl ;
Ctrl .
2
Ctrl _
I insert O open P
undo line
insert
hard
Top screen
WORD
0
prev mark
Ctrl I
man page
identifier
"prev"
find
find
"next"
paste
Ctrl H
9,16
Ctrl 7
Replace
&
soft
half page
A append
append
$
3
Ctrl ^
Shift
extern filter
Caps
Ctrl 3
1
14
Tab
Ctrl @
Michael Pohoreski
michael@PeopleOfHonorOnly.com
Ctrl 1
Copyleft 2011
Esc
Ctrl \
0
"
register
'
goto mark
goto col#
16 The search direction is relative; next is the initial direction, previous is the opposite direction. n ; repeat same initial direction find. N , repeat opposite initial direction find. Note: ; , only searches cursor line, n N searches buffer.
Ex cmd line
:w save
:q quit
:e <filename>
:source %
:exec '...'
:help cmdline
:help tags
:gui switch to gui GUI :ts
list active tags
:q! quit w/o save
^]
jump to tag under cursor
^t
edit file
restore cursor before tag jump
exec cmds in cur file ^p
complete word
:ta Foo manual jump to tag 'Foo'
do cmd
:help movement
Start of Line 1st non-whitespace
:help diff
:hi DiffAdd
guifg=#rrggbb
hard
[c prev diff
Start of Line column 0
:hi DiffChange guibg=#rrggbb
]c next diff
End of Line
:help modes
#| move col #
:diffupdate
:hi DiffText gui=none
move col 0
^f page
Esc ^[ ^c
Normal
page
resync :hi DiffDelete
^d page
a i r s
Insert
page
v V ^v ^q
Visual
scroll line ^y scroll line
:help changes
0g end of file
:changes
c d y < >
Op pending
start of file
:help folding
G end of file
zR fold remove
g; older change
Command Line : / ? !
goto line #
Foo ( src , dst , len );
zo fold open
g, newer change
begin this func {
zc fold close
Note: There is no whitespace in-between 'Foo(src,' but before/after 'dst,'
begin next func {
zi invert all
Foo ( src , dst , len );
WORD
:set matchpairs=(:),{:},[:],<:>,?:\:
% goto matching { } < > [ ]
zr fold reduce
Startup
:help recording
vim <filename> +123
zm fold more
q start recording
goto line 123
:help range
vim <file> -t Foo
:s/Foo/Bar
@ playback
edit at tag 'Foo'
find Foo replace w/ Bar
vim <file> -c "/Foo" cmd: find 'Foo' & edit :s/Foo/Bar/g ...all instances on line
q stop recording
GUI vim -g
gvim
:%s/Foo/Bar
@@ repeat
or
start GUI ver.
apply to whole file
:help syntax
.,.+# cur line, cur line + # lines
GUI Linux
:set guifont=ProggyTinyTT\ 12
:syntax enable
GUI OSX
:set guifont=ProggyTiny\:h11
$ last line
:set filetype=
c cpp sh make perl python
'< start of select '> end of select
diff gvimdiff <file1> <file2> [<file3>]
Note:
means
ONE
OF
<< >>
>>
:set tabstop=#
Broken Keys Ctrl-I = Tab, Ctrl-[ = ESC
set tab stop every #th col
Code == << >> <<
:set backspace=indent,eol,start
:set expandtab!
Vim is still unable to map certain keys for your own use
toggle hard/soft tabs
Caps, Ctrl-1, Ctrl-Shift-1, Ctrl-I, Ctrl-\, etc.
^
0
$
|
^b
^u
^e
1g
#g
[[
]]
:buffer #
:buffers
:new blank file/buffer
:bn next file
:bp prev file
:bd close file
:bd! force close
:set lines=#
:set columns=#
:winpos # #
GUI
Windows
:help windows
^w or :wincmd
w!
c!
n!
s!
v!
o!
=!
h!
j!
k!
l!
!
:sp
:switch to next
:close!
:new
:split horz.
:vsplit vertical
:only maximize
all same size
move to win
move to win
move to win
move to win
[<filename>]
File / Directory
:Explore or :e .
:set browsedir=
buffer last