So i have a specific function I'd like to edit in my .vimrc, so that it work only on specific filetype (eg: .vim).
The code for this example is taken from this answer.
function OrgFold(lnum)
let level = strlen(matchstr(getline(a:lnum), '\v^\s*\zs\"+\t'))
if level > 0
return '>'.level
else
return '='
endif
endfunction
The above function essentially work on all files, but i want to know how to only make it work for .vim or whatever filetype i specify.
autocmd FileType c call OrgFold()
is a fast way (this one will work withc
files but you can placejava
,python
or other filetype if you want. You can look there for more information. – Fabrice Hategekimana Jan 25 at 0:35call
withFileType
@FabriceHategekimana – Nordine Lotfi Jan 25 at 0:41filetype
event is triggered (when filetype is set) but won't make it available forc
files only. – Biggybi Jan 25 at 1:06