code-snippet is a simple input assistance of code snippets for Vim.
Version: 071204acode-snippet is a simple input assistance of code snippets for Vim.
Operating System: Linux
This plugin provides a simple input assistance of code snippets. A code snippet is an idiom much used in source codes or marked-up texts. Here are the basic steps to use (and they are almost all):
1. Register snippets (generally in filetype plugins).
2. Type a trigger string in the insert mode.
3. Press < S-CR > or < C-CR > to expand a snippet, and jump to each next/previous placeholder.
4. Press < CR > to fill in a placeholder.
Snippets are registered as abbreviations. You can therefore expand them by pressing < Esc > like mere abbreviations.
Placeholders can contain default strings.
This plugin is well configurable. You can configure these points:
· Map commands to other keys.
· Use the select mode instead of the visual mode.
· Change the format of placeholders in general or buffer-local.
Type like this in the commandline mode.
:StringAbbrLocal fputs() "fputs([~str~], [~fp:stderr~])[~~]"
Then type like this in the insert mode.
And press < S-CR >.
The line is expanded like above and "[~str~]" is selected in the visual mode. "[~ ... ~]" is a placeholder. Each time you press < S-CR >, the cursor jumps to the next placeholder. Press < C-CR > to jump back to the previous placeholder.
When you press < CR >, the placeholder under the cursor is cut and Vim switches to the insert mode. So that you can fill in the place. Pressing < CR > at the second placeholder "[~fp:stderr~]", the default string "stderr" is inserted. If you want to insert another word, it can be deleted by pressing < C-U > (see :help i_Ctrl-U).
Extract the zip file to "$HOME/.vim/" (*nix). Then open "code-snippet.txt" with Vim under "$HOME/.vim/doc/", and type ":helptags ." as an ex command to register help files.
To enable loading plugins and indent files for particular file types, it is recomended to add this line to your .vimrc file.
filetype plugin indent on
It is not required for running this plugin, but necessary for registering snippets for particular file types. And the setting makes it easy to register multi-line snippets. See ":help filetype".
On most terminal emulators, and some other systems, < S-CR > and < C-CR > of the default key mappings may not work. In those conditions, You should therefore map the commands to other keys. See ":help code-snippet-mappings".
It is same as installing other plugins. See ":help add-plugin" and ":help add-local-help" for more information.