开发者

How to make .less files to have .css syntax highlight in Vim?

开发者 https://www.devze.com 2023-01-04 16:47 出处:网络
I\'ve been using LESS and I find it very useful I would li开发者_如何学编程ke to have CSS syntax highlight in Vim with all .less files.

I've been using LESS and I find it very useful

I would li开发者_如何学编程ke to have CSS syntax highlight in Vim with all .less files.

Any suggestions?


http://leafo.net/lessphp/vim/

Check the INSTALL file for instructions.


There are also a couple of github repos:

  • https://github.com/groenewege/vim-less

  • https://github.com/lunaru/vim-less


If you only want to use Vim's syntax highlighting, then you can set the filetype of every LESS file to be a CSS file.

To do this, you can add au BufNewFile,BufRead *.less set filetype=css to your .vimrc file.

au stands for autocommand, so the above line reads "on events BufNewFile or BufRead, if the file has a less extension, then set the filetype option to css".

Keep in mind that this is not the recommended way. According to the Vim tips Wiki:

If there is a new file extension that you want Vim to recognize, don't muck about with augroup in your .vimrc, put the settings in the right place. See :help ftdetect


Paste this line into your .vimrc:

au BufRead,BufNewFile *.less setfiletype css

au is a shorthand for autocmd. So this reads as "when I read or open a new file that ends in .less, automatically set the filetype as CSS".

0

精彩评论

暂无评论...
验证码 换一张
取 消