From 0a52d3afd9d01057c7e00b7a0c8dbee33271414e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 26 Jul 2016 21:49:50 +0200 Subject: [PATCH] Simplified s:count --- indent/tex.vim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/indent/tex.vim b/indent/tex.vim index b0a3c20..8000923 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -145,14 +145,12 @@ let s:tikz_commands = '\v\\%(' . join([ function! s:count(line, pattern) " {{{1 let sum = 0 - let indx = match(a:line, a:pattern) - while indx >= 0 + while 1 + if match(a:line, a:pattern, 0, sum + 1) == -1 + return sum + endif let sum += 1 - let match = matchstr(a:line, a:pattern, indx) - let indx += len(match) - let indx = match(a:line, a:pattern, indx) endwhile - return sum endfunction " }}}1