create
memorize
share

Vim 2

edit

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
start learning
start learning

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
start learning
start learning

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
start learning
start learning

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)
start learning
start learning

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
start learning
start learning

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
start learning
start learning

Macros

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

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 :
start learning
start learning

 

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
start learning
start learning

Packages

PackageDescription
netrwedit files remotely
vimshellrun shells within vim (unix-only)
:Nread scp://you@yourserver.com/view remote directory
start learning
start learning
blog comments powered by Disqus