Vimmage

This is where I put vim tips I want to remember.

Help

Help search with regex: :helpgr
Show help topics with beginning foo: :he foo

Must have plugins

minibuf
tlist
visinc.vim
surround
snippetsEmu

Replacing each line in a block select

Pressing s while in a block selection (ctrl-v) will let you write something in place of your selection, which will repeated for every line in the block selection when you press escape. Like pasting while in a block selection will do in ultraedit.

I and A act the same, but inserts or appends the text instead.

Search/replace

Global search/replace:%s/find/replace/g
Landing the cursor on offsets from the search result: :he search-offset

Handy shorthands

^ instead of .* in regex
% instead of 1,$ in ranges

Filenames

Open filename under cursor: gf
Split window and open filename under cursor in new window: ctrl-w f
Complete filename (insert mode): ctrl-x ctrl-f

Numbers

Increment numbers: ctrl-a
Turning off vims idea that the number is octal: setnrformats -= octal

The vim regex guide

Completion

Complete from previous/next matching text in the same document: Ctrl-p/n
Include dictionary in completion loop: :set complete-=k complete+=k

Command line

Pipe output into vim: ls -l | vim – (notice the -)
Read output from external command: :r!ls -lA
Paste clipboard into commandline: ctrl-r + or ctrl-r * (depending on the register)
Paste word under cursor into commandline: ctrl-r ctrl-w

For complete command line ctrl-r command list: :he c_CTRL-R

Other vim tip pages

http://rayninfo.co.uk/vimtips.html

Causes problems over slow connections (like VPN):
matchparen.vim
netrwPlugin.vim
vimballPlugin.vim

Leave a Reply