Create
Learn
Share

Vim 2

rename
Updated 2006-10-28 00:38

Windows

ActionKey
close frame (saving changes)ZZ
split window^ws
close window^wc
close all other windows^wo
next window^w^w
previous window^wk
go to 3rd window3^w^w
memorize

Windows II

Question Answer
new file (in new window)^wn
move window down^wr
move window up^wR
move up^w^k
move down^w^j
recenterzz
memorize

Buffers / Replacing

ActionKey
close buffer:bd
see all *txt* buffers:b txt [tab]
go to next search itemn
go to previous search itemN
Search and replace (on current line):s/old/new/g
Search and replace (on all lines):%s/old/new/g
memorize

Selecting and copying

ActionKey
start selectingv
copy (vim clipboard)y
paste (vim clipboard)p
copy (windows clipboard)^c
paste (windows clipboard)^v
select all^a
jump to other end of selectiono (while selecting)
memorize

Advanced selecting and copying

ActionKey
create mark named ama
jump to mark named a`a
copy current lineyy
select current lineV
copy up to ay/a
select what you last had selectedgv
memorize

Advanced inserting

ActionKey
insert (after current line)o
insert (beginning of current line)I
insert (above current line)O
insert ls output (at current point):r !ls
insert f.txt (at current point):r f.txt
memorize

Macros

ActionKey
start recording macro (named a)qa
stop recording macroq
execute macro (named a)@a
rerun last macro@@
memorize

Helpful config file (.vimrc) settings

Question Answer
set incsearchincremental searching
set ignorecasecase insensitive searching
set g:netrw_keepdir=0set current dir, when viewing a dir
:nmap ; :make ; key behave like :
memorize

 

The last one is useful because it saves you from having to hold down the shift key (while typing a command, such as :w)

Misc II

Question Answer
undo all changes to current lineU
show help:h
help for the set command:h set
vim irc channelirc.openprojects.net #vim
Plugin to helps navigate buffersbufexplorer
autocompletion^p (while inserting)
:abbreviate h helloabbreviate h as hello
memorize

Packages

PackageDescription
netrwedit files remotely
vimshellrun shells within vim (unix-only)
:Nread scp://you@yourserver.com/view remote directory
memorize