Thanks for the answer!
The split on '\zs' was new to me. Made some speed tests and found that for lines with more than 180 chars the first solution is faster, and for shorter lines the solution below, which is based on the split() approach. Opted for the new solution as short lines are much more common.
function! CWord(string, class_start, class_end)
let l:chars = split(a:string, '\zs')
let l:len = len(l:chars)
let l:pos = virtcol(".") - 1
let l:start = l:pos
while l:start >= 0 && l:chars[l:start] =~ a:class_start
let l:start -= 1
endwhile
let l:end = l:pos
while l:end < l:len && l:chars[l:end] =~ a:class_end
let l:end += 1
endwhile
return join(l:chars[l:start + 1:l:end - 1], '')
endfunction
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment