vim default syntax for files with no extension

后端 未结 3 1700
夕颜
夕颜 2021-01-11 11:42

How do I set up a default syntax for files that have no extension in vim?

3条回答
  •  囚心锁ツ
    2021-01-11 12:26

    To pick the default syntax for files without an extension, you can create an autocommand that checks if the filename contains a ., and if not, switches to the desired syntax:

    autocmd BufNewFile,BufRead * if expand('%:t') !~ '\.' | set syntax=perl | endif
    

    This one picks perl as a default syntax, but you can simply use whichever is appropriate.

提交回复
热议问题