I am editing a source code in language1.
It doesn't have a built-in syntax highliting configuration into my vim.
However, its syntax is very similar to language2, which has. I think, syntax highliting the sources as language2 would be pretty okay for me. Thus, I tried to set up the syntax highliting of language2 to the files with extensions of language1.
Checking the syntax highliting configuration of my distribution-provided vim (filetype.vim
), I found the line
au BufNewFile,BufRead *.<ext2> setf language2
Thus, I inserted a line
au BufNewFile,BufRead *.<ext1> setf language2
into my local .vimrc
.
However, nothing happened. My source files - in language1 - are still un-syntax highlited.
Why is it so? How could I make it working?
.ts
) as if they would be Javascript, on a vim provided by debian/ubuntu. This is why I am trying to avoid to overwrite the distro-provided/usr/share/vim/vim74/filetype.vim
. However, I tried to make the question as general as possible (I think not the question and also not the answer won't be specific to my environment). – peterh says reinstate Monica Feb 18 '18 at 22:55/usr/share/vim/vim74/filetype.vim
, then it works, but I am trying to use a local config, as overwriting distro-provided file is a bad thing on debian. – peterh says reinstate Monica Feb 18 '18 at 22:57set filetype=language2
work (i.e., not usingsetf
)? – Mass Feb 18 '18 at 23:23au
command didn't work in my local vimrc? – peterh says reinstate Monica Feb 18 '18 at 23:31au BufNewFile,BufRead *.<ext1> set filetype=language2
in your vimrc already? The reasonset filetype
works andsetf
doesn't is because vim already knows.ts
as having filetype=xml.setf
will not change the filetype if it's already set (I will add an answer if the code works in your vimrc). – Mass Feb 18 '18 at 23:34