How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files?
What do I put in my vim conf开发者_如何学Cig? How do I change it?
I want it to be like .html extension...because it is html...
I think you need
au BufRead,BufNewFile *.ejs setfiletype html
au
is short for autocmd
docs
It's also a good idea to put it inside a test
if has("autocmd")
au BufRead,BufNewFile *.ejs setfiletype html
endif
To avoid error messages if you ever use a cut-down version of Vim that doesn't support this feature.
Finally, if you have a default filetype rule like:
au BufRead,BufNewFile * setfiletype text
then the *.ejs
rule must be above it.
This worked well for me:
au BufEnter *.ejs :setl filetype=html
source: How do I tell vim that some file extensions are synonymous?
Digging into the vim docs
BufEnter - "After entering a buffer. Useful for setting options for a file type. Also executed when starting to edit a buffer, after the BufReadPost autocommands." source: BufEnter
:setl - "Like :set but set only the value local to the current buffer or window. Not all options have a local value. If the option does not have a local value the global value is set..." source: :setlocal
精彩评论