Enable syntax highlighting for various filetypes in vim

前端 未结 4 580
自闭症患者
自闭症患者 2020-12-08 15:09

I can enable syntax highlighting for a file that has an extension that is unknown to vim by doing the following

set syntax=c

Eve

相关标签:
4条回答
  • 2020-12-08 15:15

    With autocommand. E.g.

    au BufNewFile,BufRead *.xyz setf c
    
    0 讨论(0)
  • 2020-12-08 15:15

    In your home directory, create the .vim/ftdetect/xyz.vim:

    au BufRead,BufNewFile *.xyz set filetype=c    " to overrule an existing filetype
    au BufRead,BufNewFile *.xyz setfiletype c     " to set it only if no filetype has been detected for this extension
    
    0 讨论(0)
  • 2020-12-08 15:22

    Put this at the end of your .vimrc (I'm assuming you have autocommands enabled).

    autocmd BufRead,BufNewFile *.xmlx set filetype=xml
    
    0 讨论(0)
  • 2020-12-08 15:36

    You can set it in the vim config file:

    http://beerpla.net/2008/04/02/how-to-add-a-vim-file-extension-to-syntax-highlighting/

    0 讨论(0)
提交回复
热议问题