call a function in vim when opening a file with a specific name ignoring directories (regex as a variable) -
i'm trying make vim check filename of file it's open
if @%== .\+"notes.tex" highlight done ctermbg=blue ctermfg=white guibg=#292960 guifg=#aaaaaa match done /.\+itemize.\+/ endif
i'd script work on file notes.tex regardless of directory. reason pu .+ before notes because want match preceeding characterrs in filename
in other words want if match "notes.tex" , "../notes.tex"
i think you'd better of using expand("%")
function read filename, , using matchstr()
check it:
if matchstr(expand("%"),"notes\.tex$") != "" highlight done ctermbg=blue ctermfg=white guibg=#292960 guifg=#aaaaaa match done /.\+itemize.\+/ endif
note $
in matchstr
statement: matches "notes.tex" if @ end of string.
the nice approach doesn't care slash direction (\
or /
) , therefore should platform independent.
hope helps.
Comments
Post a Comment