New Location

My website has moved to http://www.jasonwhaley.com. Please visit there for the latest and only remain here for legacy content.

Saturday, June 5, 2010

Periodically VIM - running commands at process start

[Periodically VIM is my regular VIM tips and discoveries section, inspired by what was Daily VIM]

The Tip: vim -c allows you to run commands you would normally type after vim had started with :cmd at the time vim starts but doesn't rely on having the commands persisted in your .vimrc file.

Usage: When you start vim from the command line, use vim -c 'cmd'. For instance (and this is based on a post from superuser.com) vim file1 -c 'split file2' opens file1 and file2 in a horizontal split. You can even chain them together as shown in the link to superuser.com.

What Is It Good For?: For when you want to start vim with commands run that aren't used enough by default to warrant inclusion in to .vimrc. You could also use a shell alias like alias vimsplit='vim -c "split"' to open vim with split windows instead the usual default of one.

0 comments: