| abstract
| - A Vim plugin or script can define new key maps to let the user invoke the commands and functions provided by the plugin. A Vim plugin can also invoke key maps defined by other Vim plugins. A plugin can choose to map any available key. But to avoid surprising (annoying) the user, it is better not to use the keys that already have pre-defined functionality in Vim. In a Vim plugin, the ":normal" command is used to execute normal mode commands. For example, the "gqip" normal mode command is used to format a paragraph. To invoke this command from a Vim plugin, the following line can be used: normal gqip If any of the keys in "gqip" is mapped, then the mapped key sequence will be executed. This may change the expected behavior of the "gqip" command. To avoid this, add the "!" suffix to the "normal" command: normal! gqip With the "!" suffix, the "normal" command executes the built-in functionality provided by Vim for the specified sequence of keys. To invoke a script local function, defined with the "s:" prefix, from a map, you have to prefix the function name with . You cannot use the "s:" prefix for the script-local function, as the map will be invoked from outside of the script context. :inoremap InsertFunc() A plugin may map one or more keys to easily invoke the functionality provided by the plugin. In the plugin functions used by these types of maps, it is advisable not to alter user Vim option settings, register contents and marks. Otherwise, the user will be surprised to see that some options are changed after invoking a plugin provided map.
|