Wednesday 3 November 2010

Checking Out a File from "vi"

Article #:11Created:03/06/07Modified:11/03/10Tags:editor, vi, vim

How do I check out a file from Perforce when already in vi?

Have you ever opened a file in vi and then realized you need to check it out in order to edit it? Add the following code to your .exrc, and you can do a p4 edit on the current file from within the editor with one keystroke:

map ^O :!p4 edit "%"^[:set noro^[

When you type this line of code into the .exrc file, you have to enter ^O by hitting control-V then control-O, and you have to enter ^ by hitting control-V then ESC.

The code addition sets ^O (control-O) to run the p4 edit command on the current file, and then sets the file (for vi's purposes) to read/write.

8 users have rated this article 4.6 out of 5

View the original article here

No comments:

Post a Comment