Checking Out a File from "vi"

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

Info & Tags

Article #:
11
Created:
03/06/07
Modified:
01/09/08

PROBLEM

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

SOLUTION

Have you ever opened a file in vi and then realized you need to check it out in order to edit it? Put this in your .exrc and you'll be able to 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 into the .exrc file, you have to enter ^O by hitting control-V then control-O, and ^[ by hitting control-V then ESC.)

This will make ^O (control-O) run the p4 edit command on the current file, and then set the file (for vi's purposes) to read/write.