Following on from Put variable to line above current line VIm
I added some logic to only run if the begin and end tags in the list are present, snippet
....
let findStart='<'.taglist[s1].'>'
let findEnd='<'.'\/'.ns.taglist[s1].'>'
let fs=0
let fe=0
while something
let fs=search(expand(findStart))
let fe=search(expand(findEnd))
if ( &fs>0 && &fe>0 )
call search(findStart,'b')
"paste the beginning fold
:-1put =foldbegin
.....
:let fs=0
:let fe=0
endif
let something=something +1
endwhile
In modeline this :let fs=0|:call search('<')|echo fs
returns the position of the search. In Vimscript the only way I can use the variable in an if statement is if ( &fs>0 ... )
.
I can't find anything to explain why the statements work differently so I can make sense of it. Any suggestions of where to look for answers?
Also :let fs=0
within the if doesn't reset the variable. Why?
UPDATE: It's something to do with using 2 letter variables but I don't know what the issue is despite googling it.
let l:fs = 0
makesfs
as a local variable for your function and prevent you from interact with global, options etc.g:
to access global variables.