VimPlugin: vim-snipmate: Difference between revisions
From wikinotes
(→Usage) |
|||
Line 64: | Line 64: | ||
func! SnipmateChooseOrComplete() | func! SnipmateChooseOrComplete() | ||
if pumvisible() | if pumvisible() | ||
" when completer visible, repeating key selects next snippet | |||
call feedkeys("\<Down>") | call feedkeys("\<Down>") | ||
else | else |
Revision as of 15:26, 21 July 2022
vim snippets in envine written in viml.
Documentation
Locations
~/.vim/snippets/${filetype}.snippets
snippet files
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
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 func! SnipmateChooseOrComplete() if pumvisible() " when completer visible, repeating key selects next snippet call feedkeys("\<Down>") else if len(l:completions) == 1 " when only one completion remains, expand snippet call feedkeys("\<Plug>snipMateTrigger") else " choose from available completions 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