*perforce.txt* A feature Rich Perforce SCM Integration for Vim. Requires Vim 6.0 Last Change: 01-Sep-2006 @ 16:54 Since Version: 1.4 Revision: 1.3.0 Plugin Version: 4.1 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-syntax| Perforce syntax plugin. |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-commands| Some useful commands and mappings. |perforce-utils| Additional utilties (perforce/perforceutils.vim). |perforce-API| New API provided by the plugin (experimental). |perforce-tips| Some useful tips. |perforce-limitations| Current limitations of the plugin. |perforce-troubleshooting| Some notes how to trouble shoot problems. |perforce-changes| A change list for current version from previous versions. |perforce-known-issues| A list of known bugs. |perforce-wishlist| Wishlist items that may be worth doing for a future version. |perforce-bugreporting| Reporting bugs. |perforce-acknowledgements| Acknowledgements. ============================================================================== *perforce-installation* To install, place the perforce.vim script in one of the runtime plugin directories along with the genutils.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 The distribution contains the following files: - plugin/perforce.vim - Thin interface to the plugin (autoload/perforce.vim). - autoload/perforce.vim - The perforce plugin itself loaded on demand. - ftplugin/perforce.vim - The perforce filetype plugin file. See below on how to configure the perforce filetype. - syntax/perforce.vim. - Syntax definition file for perforce forms. - doc/perforce.txt. - The online help file (this file). - perforce/perforcemenu.vim. - Additional module to install and configure a menu for the plugin. See |perforce-menu|. - perforce/perforcebugrep.vim. - An utility script that can be used to generate useful information while sending bugreports about the plugin. See |perforce-bugreporting|. - perforce/perforceutils.vim. - Thin interface to autoload/perforceutils.vim - autoload/perforceutils.vim - Additional misc. utilities loaded on demand. 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 |p4ClientRoot| 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. - The plugin requires that you have Vim 7.0 version installed. - If you want to enable the perforceutils.vim plugin, add the following line to your vimrc: > runtime perforce/perforceutils.vim < - If you want to enable the menu, add the following line to your vimrc, at the end of perforce configuration lines: > runtime perforce/perforcemenu.vim < - The core of the plugin is autoloaded by Vim the first time a perforce command needs to be executed. This improves the startup time of Vim considerably in some situations. If you want the plugin to be loaded immediately, you can force an autoload by adding the following command to your vimrc: > PFIntialize < 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. *loaded_perforce* Later, if you need to temporarily disable the plugin without needing to remove the files, 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 all 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|, |p4DefaultPreset|, |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|, |p4CurPresetExpr|, |p4CurDirExpr|, |p4UseClientViewMap| *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' < *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 |PFSwitch| command. Set this variable in your vimrc with a comma separated list of settings. Each setting should be of the form (separated 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 |PFSwitch| 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. :PFSwitch 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-P4CONFIG* *P4CONFIG* As a special case, you can have one of the specifications as "P4CONFIG", allowing you to switch to the P4CONFIG feature of external p4 command interactively, see |perforce-dynamic-client|. > :let g:p4Presets = 'p1 c1 u1,P4CONFIG,p2 c2 u2' < Setting port field to "P4CONFIG" also has the same effect. This results in plugin not passing the options for port, client and user explicitly such that p4 can determine them based on the P4CONFIG file. However you can still override them by explicitly specifying the corresponding option to PF command. *p4DefaultPreset* If you don't have the P4CLIENT, P4USER and P4PORT environment variables set, you can use this setting to initialize the plugin with corresponding values. The format for the value is exactly same as a single entry in |p4Presets| setting. In fact, you can also set this to an index in the |p4Presets|. > :let g:p4DefaultPreset = ' ' < Example: > :let g:p4DefaultPreset = 'localhost:1666 hari_client hari' :let g:p4DefaultPreset = 2 " Start with the second setting in p4Presets. < Note that the plugin automatically chooses some defaults for the above based on your environment, if you don't explicitly set them in your startup script. *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-buffer-local-options* In addition you can also use the buffer local variables "b:p4Options", "b:p4Client", "b:p4User", "b:p4Port" and "b:clientRoot" to override the global options (see ":PH usage" for option list) at a buffer level. The plugin automatically sets these options whenever you create a new perforce result window such that any future commands originating from the same window automatically inherit them. This is especially useful when you temporarily switch to a different client/user by providing one at command-line, and later do more operations on the results (provided the given client/user is valid on the current m/c). > :PF -c hari_tmp opened :PFileDiff > The PFileDiff will automatically use the "hari_tmp" client as b:p4Client is set to that value. You can also use b:p4Options to set any option that is accepted in the global options section of PF command (see |perforce-global-options|), however for the client view mapping to work correctly, you need to have b:p4Client and b:clientRoot set. > :let b:p4Options = '-H my_host' < All commands executed when this buffer is active will automatically inherit these global options. NOTE: Currently the b:clientRoot variable needs to be set manually. *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 autoload 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' < If |p4EnableActiveStatus| is disabled, the current directory is used as the default. *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 still manually checkout (or edit) the file even when this option is disabled by using "PE" or "PF edit" command. When the checkout prompt is given, you have the option saying Yes, No or Cancel. When accidental changes to the buffer bring up the checkout prompt, you can select Cancel to revert the state of the buffer as much as possible (you may still have to press sometimes). One advantage of selecting Cancel in these cases is that the next time you start making a genuine change, you will get the checkout prompt as expected (otherwise, you will only get this prompt once). *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 = '-dwbu5' < For the options that you can set here, see the help for "diff" or "diff2" by running the "PH diff" or "PH diff2" command. Note, this setting can't be used to specify options to the external diff program. *perforce-menu* *p4EnableMenu* The distribution comes with an additional module called perforcemenu.vim to install a Perforce sub-menu on the main or PopUp 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 < *loaded_perforcemenu* Note: If you never use the menu features of the plugin, consider setting "loaded_perforcemenu" to a non-zero value, to avoid getting this module sourced. *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 checked out 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 =