Fixed stupid bug in motion.vim

This commit is contained in:
Karl Yngve Lervåg 2013-11-02 17:46:43 +01:00
parent 8bef60eed8
commit 09dca6defa

View File

@ -352,6 +352,37 @@ function! s:highlight_matching_pair(...)
endfor endfor
endif endif
endfunction endfunction
" {{{1 s:search_and_skip_comments
function! s:search_and_skip_comments(pat, ...)
" Usage: s:search_and_skip_comments(pat, [flags, stopline])
let flags = a:0 >= 1 ? a:1 : ''
let stopline = a:0 >= 2 ? a:2 : 0
let saved_pos = getpos('.')
" search once
let ret = search(a:pat, flags, stopline)
if ret
" do not match at current position if inside comment
let flags = substitute(flags, 'c', '', 'g')
" keep searching while in comment
while latex#util#in_comment()
let ret = search(a:pat, flags, stopline)
if !ret
break
endif
endwhile
endif
if !ret
" if no match found, restore position
call setpos('.', saved_pos)
endif
return ret
endfunction
" }}}1 " }}}1
" vim:fdm=marker:ff=unix " vim:fdm=marker:ff=unix