Skip to content

Instantly share code, notes, and snippets.

@tungd
Created November 4, 2011 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tungd/1339310 to your computer and use it in GitHub Desktop.
Save tungd/1339310 to your computer and use it in GitHub Desktop.
Fix neocomplcache snippet expand when gdefault is set
diff --git a/autoload/neocomplcache/sources/snippets_complete.vim b/autoload/neocomplcache/sources/snippets_complete.vim
index f229823..87e9cc7 100644
--- a/autoload/neocomplcache/sources/snippets_complete.vim
+++ b/autoload/neocomplcache/sources/snippets_complete.vim
@@ -528,7 +528,11 @@ function! s:expand_newline()"{{{
while match >= 0
let end = getline('.')[matchend(getline('.'), '<\\n>') :]
" Substitute CR.
- silent! s/<\\n>//
+ if &gdefault
+ silent! s/<\\n>//g
+ else
+ silent! s/<\\n>//
+ endif
" Return.
let pos = getpos('.')
@@ -722,7 +726,7 @@ function! s:substitute_marker(start, end)"{{{
while line <= a:end
if getline(line) =~ marker
let sub = escape(matchstr(getline(line), '\$<'.cnt.':\zs.\{-}\ze\\\@<!>'), '/\')
- silent! execute printf('%d,%ds/$%d\d\@!/%s/g',
+ silent! execute printf('%d,%ds/$%d\d\@!/%s/'.(&gd ? '' : 'g'),
\a:start, a:end, cnt, sub)
silent! execute line.'s/'.marker.'/'.sub.'/'
break
@@ -733,7 +737,7 @@ function! s:substitute_marker(start, end)"{{{
elseif search('\$<\d\+\%(:.\{-}\)\?\\\@<!>', 'wb') > 0
let sub = escape(matchstr(getline('.'), '\$<\d\+:\zs.\{-}\ze\\\@<!>'), '/\')
let cnt = matchstr(getline('.'), '\$<\zs\d\+\ze\%(:.\{-}\)\?\\\@<!>')
- silent! execute printf('%%s/$%d\d\@!/%s/g', cnt, sub)
+ silent! execute printf('%%s/$%d\d\@!/%s/'.(&gd ? '' : 'g'), cnt, sub)
silent! execute '%s/'.'\$<'.cnt.'\%(:.\{-}\)\?\\\@<!>'.'/'.sub.'/'
endif
endfunction"}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment