Some vim tips

svn diff the current windows file

Put this in your vimrc:

map zs :!svn diff % > /tmp/vimsvndiff<CR><CR>
  \ :new<CR>:r /tmp/vimsvndiff<CR>
  \ :set ft=diff<CR>

Say you’re editing a checked out file and what to see what changes you’ve done without leaving your VIM session? Just type zs when in normal mode. This will open the diff in a new split window.

Apply tabs to a block of text

I found myself doing this often. Visual selecting some text and then applying a regex to prepend some spaces (or a tab) to each line

Put this in your vimrc:

map <C-i> :s/^/ / :nohlsearch
map <C-p> :s/^ // :nohlsearch

So Control-i will insert 4 spaces for all lines of the selected text. Control-p will remove 4 spaces. Very handy!

2 Responses to “Some vim tips”

  1. Alan Haggai Alavi Says:

    Hi Rohan,

    For (un)indenting code in a visual selection in Vim, double arrows can be used:

    >> - indents code

  2. rohan Says:

    Yeah, I came to know about the > and < commands a bit too late! :)

Leave a Reply