Browse files

change the formatoptions while the snippet is expanding

this is useful to stop comment leaders being added at the start of each
line etc
  • Loading branch information...
1 parent 1f23450 commit e4acfe9e148b1ff7d6da530a88105e369a0ac33f @scrooloose committed Feb 10, 2009
Showing with 14 additions and 1 deletion.
  1. +14 −1 plugin/NERD_snippets.vim
View
15 plugin/NERD_snippets.vim
@@ -43,7 +43,7 @@ let s:snippets = {}
let s:snippets['_'] = {}
function! s:enableMaps()
- exec "inoremap ".g:NERDSnippets_key." <c-r>=NERDSnippets_ExpandSnippet()<cr><c-g>u<c-r>=NERDSnippets_SwitchRegion(1)<cr>"
+ exec "inoremap ".g:NERDSnippets_key." <c-o>:call NERDSnippets_PreExpand()<cr><c-r>=NERDSnippets_ExpandSnippet()<cr><c-o>:call NERDSnippets_PostExpand()<cr><c-g>u<c-r>=NERDSnippets_SwitchRegion(1)<cr>"
exec "nnoremap ".g:NERDSnippets_key." i<c-g>u<c-r>=NERDSnippets_SwitchRegion(0)<cr>"
exec "snoremap ".g:NERDSnippets_key." <esc>i<c-g>u<c-r>=NERDSnippets_SwitchRegion(0)<cr>"
endfunction
@@ -93,6 +93,19 @@ function! NERDSnippets_ExpandSnippet()
return snippet
endfunction
+function! NERDSnippets_PreExpand()
+ let b:NERDSnippets_old_format_options = &fo
+ setl fo-=t
+ setl fo-=c
+ setl fo-=r
+ setl fo-=a
+ setl fo-=n
+endfunction
+
+function! NERDSnippets_PostExpand()
+ let &l:fo = b:NERDSnippets_old_format_options
+endfunction
+
"jump to the next marker, remove the delimiters and select the text inside in
"select mode
"

0 comments on commit e4acfe9

Please sign in to comment.