VimPlugin: vim-snipmate
From wikinotes
vim snippets in envine written in viml.
Documentation
Locations
~/.vim/snippets/${filetype}.snippets
snippet files ~/.vim/snippets/_.snippets
global snippets
Install
Plug 'https://github.com/marcweber/vim-addon-mw-utils' Plug 'https://github.com/tomtom/tlib_vim' Plug 'https://github.com/garbas/vim-snipmate'
Configuration
" version of snippets-fileformat to use let g:snipMate { 'snippet_version': 1 }
Usage
Basics:
- By default, triggering completion is bound to tab key.
- If there are multiple matches, use ctrl n/p to select one, then hit enter.
- Tab to move to each field in the expanded snippet.
<tab> " cycle available, or choose from completion <c-r><tab> " (from insert) list avail completions
Tips n Tricks
Custom Trigger
NOTE:
some completers have additional plugins to integrate snippets. ex coc-snippets
Snipmate may not play nice with your tab keybindings.
Since it's keybindings must be executed within insert mode, it may be useful to write your own entrypoint." function to execute in place of snipmate's completer " - when completer visible, repeating key selects next snippet " - when only one completion remains, expand snippet " - otherwise, choose from available completions func! SnipmateChooseOrComplete() if pumvisible() call feedkeys("\<Down>") else if len(l:completions) == 1 call feedkeys("\<Plug>snipMateTrigger") else call feedkeys("\<Plug>snipMateShow") endif endif endfunc " bind a '<Plug>' command, (since we can execute it from insert mode) inoremap <silent> <Plug>SnipmateChooseOrComplete <C-R>=<SID>SnipmateChooseOrComplete()<CR> " create your keybinding imap <c-j> <Plug>SnipmateChooseOrComplete