How to make Vim and Perforce work together in three easy steps

by simpsonjulian on September 2, 2008

(Vim logo from http://www.vim.org/)

Step 1: Make sure that the perforce client is in your path. Can you open a shell (or command prompt) and type ‘p4′? Do you get a help message from Perforce?

Step 2: Open the .vimrc file (on Windows, look for a _vimrc file) in your home directory. If you don’t have one, now’s the time to make it. Paste in the following and then close Vim:

nnoremap @p4a :!p4 add %:e
nnoremap @p4e :!p4 edit %:e
nnoremap @p4d :!p4 diff %

Step 3: Go to a file that is managed by Perforce (i.e. with the no read permissions). Open it. In Normal mode, type the following:


@p4e

Rejoice as Vim checks the file out for you. How to check it back in again? Do that from your command line or GUI client. There’s no such thing as a free lunch …

Did you like this? Please share it if you did!
  • Digg
  • del.icio.us
  • Facebook
  • DZone
  • Slashdot
  • StumbleUpon
  • DotNetKicks
  • E-mail this story to a friend!
  • Reddit

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>