Skip to content

Commit

Permalink
add second example illustrating how to implement suggestion by JuanPa…
Browse files Browse the repository at this point in the history
…blo -> #49
  • Loading branch information
MarcWeber committed Sep 25, 2011
1 parent 132029e commit b9efaa5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions doc/snipMate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,39 @@ plugin/snipMate.vim assigns three important keys:
You can override all of those settings.

You can see that the default set of snippets is determined by Vim's |rtp|.

Example 1: ~
autoload/snipMate_python_demo.vim shows how you can register additional
sources such as creating snippets on the fly representing python function
definitions found in the current file.

Example 2: ~
Add to your ~/.vimrc: For each know snippet add a second version ending in _
adding folding markers
>
fun! AddFolding(text)
return "# {{{1\n".a:text."\n# }}}"
endf
fun! SnippetsWithFolding(scopes, trigger, result)
" hacky: temporarely remove this function to prevent infinite recursion:
call remove(g:snipMateSources, 'with_folding')
" get list of snippets:
let result = snipMate#GetSnippets(a:scopes, substitute(a:trigger,'_\(\*\)\?$','\1',''))
let g:snipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding')
" add folding:
for k in keys(result)
let a:result[k.'_'] = map(result[k],'AddFolding(v:val)')
endfor
endf
" force setting default:
runtime plugin/snipMate.vim
" add our own source
let g:snipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding')
<

More details about all possible relative locations to |rtp| can be found in
|snipMate-syntax|

Expand Down

0 comments on commit b9efaa5

Please sign in to comment.