39

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

I would like to have CSS syntax highlight in Vim with all .less files.

Any suggestions?

4 Answers 4

37

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

Check the INSTALL file for instructions.

Sign up to request clarification or add additional context in comments.

2 Comments

Would be useful if you provided the actual information in the answer and not only a link meta.stackexchange.com/questions/8231/…
You should quote the explanation, paraphrase it, or add your own explanation rather than post a link to it. If the link one day becomes broken, your answer is no longer helpful. In fact the link seems to be broken as I write this comment.
20

There are also a couple of github repos:

2 Comments

groenewege/vim-less is working better for me than lunaru's and lessphp's.
as jo liss says, groenewege is what you want. it goes nicely with two other plugins. if you have pathogen installed, you can just run these three git commands in your ~/.vim/bundle directory: git clone https://github.com/skammer/vim-css-color.git git clone https://github.com/groenewege/vim-less git clone https://github.com/hail2u/vim-css3-syntax
13

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

1 Comment

The other reason not to do this is that there are aspects of less that vim's css syntax highlighting (correctly) considers wrong - for example nested curly braces
4

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".

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.