Reputation: 467
Similar to how spell checking works. I have a custom syntax I wish to temporary apply to any filetype in the buffer. I figure the best way to do this is just change the filetype. But, I don't know how to get back to previous filetype without being explicit. How can I accomplish this?
Upvotes: 1
Views: 134
Reputation: 51593
Set up a function
and a keyboard map to do it for you, e.g.:
function! ToggleFileType()
if g:my_file_type" == 0
let ft=MYFILETYPE
let g:my_file_type = 1
else
filetype detect
let g:my_file_type = 0
endif
endfunction
nmap <silent> ;s :call ToggleFileType()<CR>
So this way, hitting ;s (in normal mode) calls the above function, which checks which filetype is set, then toggles.
Upvotes: 1