I have a plugin that does syntax highlighting and folding for a kind of data file. The syntax and folding are both dependent on textual values in specific places (columns) of current line of text.
My plugin works, but is very slow. I'm a novice at vimscript and was hoping someone could point me to a more efficient way of extracting the appropriate textual markers
I've used the :profile
tool and found that the following lines can take the majority of the time. (These are all in the function used for folding.)
let line = getline(v:lnum)
let g:previous_mat = g:current_mat
let g:current_mat = str2nr(strpart(line, 67,3))
let g:previous_mf = g:current_mf
let g:current_mf = str2nr(strpart(line, 70, 2))
let g:previous_mt = g:current_mt
let g:current_mt = str2nr(strpart(line, 72, 3))
Now, perhaps this is the best way to do it and folding is just slow because I have large files (several hundred thousand lines is not uncommon). Please advise a vimscript novice.
prevnonblank()
?) and splitting it explicitly. – filbranden♦ Jun 3 '20 at 16:55