Error using Vim substitute method -



Error using Vim substitute method -

i using substitute() method script vim code folds different.

code in ~/.vimrc follows:

function! foldtext() allow width = winwidth(0) - &foldcolumn - (&number ? 4 : 0) allow first_line = getline(v:foldstart) . " ..." allow edited_line = subsitute(first_line, "{ \.\.\.", "{ ... }", "") allow expansion_string = repeat(" ", width) homecoming edited_line . expansion_string endfunction set foldtext=foldtext()

the problem doesn’t work, each fold:

0-------------------------------------------------------------------------------

if take out edited_line , homecoming first_line . expansion_text first part works:

class whatever { ...

but purely aesthetic reasons i’d folds start brace show brace so:

class whatever { ... }

i’ve not used vimscript much, , pinched this site, expect i’m missing basic. thanks!

the 0 comes typo in function name. when vim evaluates 'foldtext' function, apparently suppresses errors (which overwhelm editor), undefined function subsitute() returns default value 0.

additionally, (though doesn't cause harm here), should escape . in pattern, specifies regular expression, not literal text; either escape them individually ({ \.\.\.), or switching very nomagic:

let edited_line = substitute(first_line, "\v{ ...", "{ ... }", "")

vim

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -