Why not vim?

Why not, indeed. For me one of the interesting things about trying out a new graphical programmer’s editor is how I’m always reminded of a pledge I made years ago to just bite the bullet and become a vim master. After all, real men (and women) use vim, don’t they?

Pretty much all modern graphical programmer’s editors can do useful stuff like running the current document as a script at the command line or executing routine git commands.

Of course you can do both of those in tried and true vim as well. In fact, you can even do them in its graphical incarnation, gvim.

The key to running scripts inside vim is to first make sure that the editor will run its commands in the directory where the currently loaded file resides. That’s done by setting autochdir in .vimrc before getting started.

set autochdir

Executing any shell command in vim is as easy as hitting the colon key and then typing a bang (!) and the current file variable (%). If the file needs an interpreter (like a perl or python script), you should also specify the interpreter command. For example:

:!perl %

That’s all there is to it!

This entry was posted in System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).