A Pair of VIM Tricks

I often lose track of my vim sessions and try to re-open a file. This results in an annoying error dialog (which I reflexively dismiss) and kicks off a hunt for that pre-existing vim session.

A coworker pointed out how silly this was, and suggested that vim should simply auto-raise the existing window. As I have discovered, vim ships with the “edit existing” macro which does just that. I’ve added this to my vimrc:

source $VIMRUNTIME/macros/editexisting.vim

Also, I’m pretty sick and tired of .swp and ~ files cluttering up my directories. Now I use the following two commands to keep them off to the side:

set backupdir=$TEMP//
set directory=$TEMP//

Advertisements

2 Responses to “A Pair of VIM Tricks”


  1. 1 Ben Beckwith April 30, 2008 at 10:32 am

    Mark, great tips. BTW, if you haven’t come across this, it helped me a bit: If you like some of the prepackaged color schemes, you can get them to come up by default by adding “colo ” to your _vimrc. I like the pablo scheme so i added “colo pablo” to my _vimrc.

    Cheers,
    Ben

  2. 2 Mark May 1, 2008 at 5:59 am

    Hi Ben. I use the pablo scheme too! Oddly, it looks different on Windows vs Linux.


Comments are currently closed.




%d bloggers like this: