*perforce.txt* A feature Rich Perforce SCM Integration for Vim. Requires Vim 6.0 Last Change: 28-Oct-2003 @ 19:56 Since Version: 1.4 Revision: 1.0.25 Plugin Version: 2.0 Author: Hari Krishna Dara (hari_vim at yahoo dot com) *perforce-introduction* *perforce-plugin* This is a fairly complete integration with the perforce version control system for the most commonly used operations, including many administrative commands. It includes a great menu that is modelled very close to the p4win (the perforce GUI client) and is quite extensive. ============================================================================== OVERVIEW *perforce-overview* |perforce-installation| How to install the plugin. |perforce-filetype| Perforce filetype plugin and setting it up for p4. |perforce-settings| An explanation of how to configure the plugin, for both the perforce related parameters and the plugin customizations, such as enabling menu. |perforce-ruler| Setting up the ruler to show an active status of the file. |perforce-help| Browse the p4 help conveniently from within vim. |perforce-reinitialize| Describes how to reinitialize the plugin to load the latest settings from the environment without restarting vim. |perforce-commands| A description of various commands that can be issued on Vim command-line. |perforce-revisions| Specifying perforce revisions conveniently. |perforce-interactive-commands| How to execute interactive perforce commands. |perforce-forms| How to edit the perforce forms (specifications) from within vim. |perforce-submit| Special handling of submit command. |perforce-list-commands| Commands that can be used in a list of items window. |perforce-extensions| Some useful extensions in the form of new options and commands. |perforce-misc-commands| Some additional useful commands. |perforce-special-mappings| Some useful mappings. |perforce-tips| Some useful tips. |perforce-limitations| Current limitations of the plugin. |perforce-troubleshooting| Some notes how to trouble shoot problems. |perforce-changes-2.0| A change list for version 2.0 |perforce-known-issues| A list of known bugs. |perforce-wishlist| Wishlist items that may be worth doing for a future version. ============================================================================== *perforce-installation* To install, place the perforce.vim script in one of the runtime plugin directories along with the genutils.vim and multvals.vim scripts that it depends on. This typically is .vim/plugin or vimfiles/plugin directory under your home directory. To get the latest versions of these plugins, goto the following webplages: perforce.vim: http://www.vim.org/script.php?script_id=240 genutils.vim: http://www.vim.org/script.php?script_id=197 multvals.vim: http://www.vim.org/script.php?script_id=171 The distribution contains 3 files: - The perforce plugin itself (perforce.vim). - Should go into the user plugin directory. - The filetype plugin file (perforce.vim). - Should go into the user ftplugin directory. - The syntax definition file (perforce.vim). - Should go into the user syntax directory. - The help file (this file) (perforce.txt). - Should go into the user doc directory. If you obtained the plugin as a zip archive, - Just extract it in your runtime directory. - Start a new instance or go to an existing instance of vim. - Execute: > :helpt /doc < This should generate the help tags for the perforce plugin help. - Setup perforce filetype as described in |perforce-filetype| section. - Make sure p4 command is in your path or set |p4CmdPath| property. - Set the |p4CodelineRoot| property and additionally any other |perforce-settings| that you like. - Optionally set 'cmdheight' property to at least 2 to avoid seeing the more prompt for most of the messages the plugin gives. - Additionally, the plugin requires that appropriate patches are installed for Vim 6.1 before it can function properly. The patches that need to be installed are: 6.1.008 "%" didn't correctly ignore \" inside a string 6.1.039 folds are not always updated when reloading a file 6.1.094 Cygwin: files with backslashes cause problems 6.1.220 reloading a file changed outside Vim may fail b.o. an autocmd 6.1.239 extra message for missing ":endif" or ":endwhile" after CTRL-C 6.1.285 can't wipe out a buffer with the 'bufhidden' option 6.1.344 ":silent filetype" writes to the message history 6.1.364 the FileChangedShell event does not allow nesting 6.1.375 ':!dir "%"' doesn't work if file name contains spaces 6.1.378 two ambiguous buffer-local user commands obscure global one 6.1.381 window closed even when a BufWriteCmd fails to write the file 6.1.397 (extra) default diff command doesn't work with space in path There is also another important patch for autocommand pattern matching on windows that is available only in 6.2 release. Alternatively, you can get the latest source and recompile to get all of these and other important patches (that I might have missed to mention here). Note, The perforce plugin depends on the multvals.vim and genutils.vim plugins, which are required at the time of initialization. If these two plugins are not present in the |rtp| (if you are sourcing them from your .vimrc from a directory that is not present in your rtp, e.g.,), then make sure these two plugins are sourced first, in the successive order, before the perforce plugin is initialized. Note: It is important to make sure your 'shellredir' properly set such that, vim captures both the standard output and standard error messages from the external perforce command. If this is not correctly set, the plugin will not be able to show the error messages generated by p4 command to you. Also note that on Windows, if you use a UNIX like shell for your 'shell' setting, the plugin will not work correctly unless the 'shellslash' option is set. Later, if you need to temprarily disable the plugin without needing to remove the file or move it into a different directory, you can set the loaded_perforce variable in your vimrc. You can also set the no_perforce_maps to disable just the mappings defined in this plugin or no_plugin_maps to disable mappings in all the plugins (provided they honor this setting), in your vimrc. ============================================================================== *perforce-filetype* *perforce-ftplugin* The package comes with a perforce ftplugin (|filetype-plugin|) which sets a few text mode options suitable for editing the forms and a syntax plugin to colorize the spec files. The ftplugin also positions the cursor at the appropriate line based on the type of spec you are editing. When you open perforce forms from within vim using |perforce-interactive-commands|, you don't have to do anything special for this to work, but if you want the same to work while editing forms using p4 command directly, then you need to add the following lines in your scripts.vim: > if getline(1) =~ '^# A Perforce ' setfiletype perforce endif < If you do not have this file already, then you need to create it under vimfiles or .vim directory (or anywhere in your 'rtp'). For details see help on |new-filetype-scripts|. Note that you also need to enable filetype plugins for this to work, see |filetype-plugin| for more information. ============================================================================== *perforce-settings* *perforce-customizing* The plugin allows a lot of customization by reading some global variables. You can define a set of global variables in your startup script (.vimrc/_vimrc) and they are automatically read by the plugin during the Vim startup and are used for customizing the behavior. Note that all the setting names are case sensitive and the boolean settings can be set to the value 0 to disable and any non-zero number (for the matter of fact, any string will also do) to enable. All the settings can be changed at runtime without restarting vim; see |perforce-reinitialize|. The settings can also be changed at runtime, see |perforce-reinitialize|. Here is a list of all the options: |p4CmdPath|, |p4Port|, |p4User|, |p4Client|, |p4Password|, |p4DefaultOptions|, |p4ClientRoot|, |p4EnableRuler|, |p4RulerWidth|, |p4EnableActiveStatus|, |p4ASIgnoreDefPattern|, |p4ASIgnoreUsrPattern|, |p4OptimizeActiveStatus|, |p4UseGUIDialogs|, |p4PromptToCheckout|, |p4DefaultListSize|, |p4DefaultDiffOptions|, |p4EnableMenu|, |p4UseExpandedMenu|, |p4EnablePopupMenu|, |p4UseExpandedPopupMenu|, |p4Presets|, |p4MaxLinesInDialog|, |p4CheckOutDefault|, |p4SortSettings|, |p4TempDir|, |p4SplitCommand|, |p4UseVimDiff2|, |p4EnableFileChangedShell|, |p4HideOnBufHidden|, |p4Depot|, |p4Autoread|, |p4FileLauncher| *perforce-command-path* *p4CmdPath* The plugin executes the external p4 command for all its operations. By default the command is found in the PATH, but if it doesn't exist in the path you can still specify the location by using the p4CmdPath variable. > :let g:p4CmdPath = '' < Example: > :let g:p4CmdPath = '~/bin/perforce/bin/p4' < *p4Client* *p4User* *p4Port* If you don't have the P4CLIENT or P4PORT environment variables set, you can set the following in your startup file, so that the plugin passes appropriate options to the external p4 command every time it is executed: > :let g:p4Client = '' :let g:p4User = '' :let g:p4Port = '' < Example: > :let g:p4Client = 'hari_client' :let g:p4User = 'hari' :let g:p4Port = 'localhost:1666' < Note that the plugin automatically chooses some defaults for the above, if you don't explicitly set them in your startup script. *perforce-password* *p4Password* You can use this setting if your perforce server requires you to enter a password. But note that this is a clear text password, so if you would like to avoid security issues, then you should let the plugin prompt you for the password the first time you run a perforce command that requires you to enter one. There is no way to save passwords as part of the presets (|perforce-presets|), so this is the only way you can enter password. *perforce-default-options* *perforce-common-options* *p4DefaultOptions* If you need to pass in additional arguments every time the external p4 command is run, you can use the following setting. The arguments are passed to p4 literally. For the set of options that you can specify here, see perforce help for "usage" (use ":PH usage" command, see |perforce-help|) > :let g:p4DefaultOptions = '' < Example: > :let g:p4DefaultOptions = '-H hkrishna' < *perforce-client-root* *p4ClientRoot* The client root is required for certain commands (it is same as what you specify in the Root: property in the client settings), so if not specified and if the |p4EnableActiveStatus| setting is enabled, the plugin will run the "p4 info" command to read the client root setting from the perforce server. But this will introduce a short delay in vim startup time (especially if you are talking to a perforce server that is installed out side your network). To avoid this, use the following setting to specify the client root. > :let g:p4ClientRoot = '' < Example: > :let g:p4ClientRoot = 'c:/dev' < *perforce-gui-dialogs* *p4UseGUIDialogs* By default the plugin uses console dialogs for some of the prompts. This is convenient as you can then use the input-history and expression register |quote=|. But if you like, you can enable this setting to force using GUI dialogs for all the prompts. > :let g:p4UseGUIDialogs = 1 < *perforce-automatic-checkout* *p4PromptToCheckout* The plugin by default prompts you to checkout, when you start editing a readonly file under the client root. You can disable this behavior by using the following setting: > :let g:p4PromptToCheckout = 0 < Note that you can stlil manually checkout (or edit) the file even when this option is disabled by using "PE" or "PF edit" command. *perforce-list-size* *perforce-default-list-size* *p4DefaultListSize* When you execute "changes", "jobs" and "filelog" perforce commands, the number of entries is limited to 100 to avoid generating a large volume of data. But you can change the value to whatever you like: > :let g:p4DefaultListSize = 1000 < To disabling it completely (show the entire list) set it to a negative number: > :let g:p4DefaultListSize = -1 < *perforce-default-diff-options* *p4DefaultDiffOptions* You can set the default diff options to be passed to all the "diff" and "diff2" operations (both direct and indirect execution of these commands), by using the following setting: > :let g:p4DefaultDiffOptions = '-dc' < For the options that you can set here, see the help for "diff" or "diff2" by running the "PH diff" or "PH diff2" command. *perforce-menu* *p4EnableMenu* The perforce plugin comes with an option to add a Perforce sub-menu on the main menu. By default the menu is not added as many people (including myself) don't use menus (I have the entire menu bar disabled). Use the following setting to enable the Perforce sub-menu: > :let g:p4EnableMenu = 1 < The above setting will create a very basic menu with the most needed commands. This makes it easy to use shortcut keys if you have the |winaltkeys| correctly configured. To enable a more full featured menu, see |p4UseExpandedMenu|. *perforce-expanded-menu* *p4UseExpandedMenu* By default the |p4EnableMenu| option creates a full-featured menu that is modelled closely after the p4Win utility, which comes with perforce. But you can disable this and have only a basic menu with the most commonly used set of commands (this was the default for older versions of the plugin). Use the following setting in your startup script: > :let g:p4UseExpandedMenu = 0 < If you want a basic menu on the main menu (for the ease of using the shortcut keys), then you can consider having the full-featured version on the popup menu, see |p4EnablePopupMenu| and |p4UseExpandedPopupMenu| settings. *perforce-popup-menu* *p4EnablePopupMenu* This is similar to |p4EnableMenu| except that enabling this option, adds a Perforce sub-menu on the PopUp menu instead of the main menu. > :let g:p4EnablePopupMenu = 1 < *perforce-expanded-popup-menu* *p4UseExpandedPopupMenu* This is similar to |p4UseExpandedMenu| except that enabling this option, adds a more full-featured Perforce sub-menu on the PopUp menu. > :let g:p4UseExpandedPopupMenu = 1 < *perforce-presets* *p4Presets* This is a useful setting when you work with multiple perforce installations at the same time. This allows you to predefine a set of configurations that you can switch between without needing to restart vim or manually enter the details while using the |PSwitch| command. Set this variable in your vimrc with a comma separated list of settings. Each setting should be of the form (separate with one or more spaces): > < You can include as many of these specifications as you want, just separate them with commas. > :let g:p4Presets = 'port1 client1 user1,port2 client2 user2' < Once set, you can use the |PSwitch| command in one of three ways to choose the setting. 1. If you know the index of the setting to which you want to switch to (starting with 0), just pass that as an argument to the command as > " Switch to the third setting. :PSwitch 2 < 2. If you don't know the index, just invoke the command without any arguments. You will be prompted to enter the index after displaying a list of available settings. 3. If you have expanded menu enabled (see |p4UseExpandedMenu| or |p4UseExpandedPopupMenu|), then you can choose the desired setting to switch to using the "Settings" sub-menu under "Perforce" group. *perforce-max-lines-in-dialog* *p4MaxLinesInDialog* Commands that use a dialog box to show the result (such as |PEdit|) assume that the messages generated by the perforce command are only a few lines. But depending on the arguments (e.g., "PEdit ..." and there are many files under the current directory ...), there can be too many lines to display in a dialog so the display mode is automatically switched to a new window instead of the dialog. Though the default limit is 1, which helps to draw your attention for the conditions that you normally expect a one line result (e.g., you checkout a file and someone else already checkedout the file), you can change it by setting the following line: > :let g:p4MaxLinesInDialog = < Example: > :let g:p4MaxLinesInDialog = 5 < *p4CheckOutDefault* When you start modifying a read-only file, the plugin prompts you to checkout the file from perforce. Set this option to 1 to make the default option to "Yes" and 2 for "No". The default is 2 to avoid accidentally checking out a file. > :let g:p4CheckOutDefault =