4

How can I tell kate to use CSS highlighting for .less files by default?

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306
wayne
  • 151
  • 1
  • 6

3 Answers3

9

Settings → Configure Kate → Open/save → Modes & filetypes → Download highlighting files.

No need to go to a website to copy any files or change any settings, just go to your Kate settings and simply download the Less CSS highlighting file that is available through the GUI. Somebody made it very easy.

slhck
  • 223,558
  • 70
  • 607
  • 592
nilli
  • 91
  • 1
  • 2
1

point your browser to https://github.com/mtorromeo/kate-syntax-files/blob/master/less.xml click on raw and "save file as" to ~/.kde/share/apps/katepart/syntax this way you will always get the last version and not the day Rob W posted the commands.

I think there is no option needed additional to that. But you only have to go to settings -> configure kate -> open/save -> modes & filetypes inside kate to edit what syntax files to be used for what filetypes. No need to edit files for that, good hidden option tough ;).

It's not recommended to use the css syntax for less because it simply not enough and it comletly breaks after comments among other stuff.

wayne
  • 151
  • 1
  • 6
0

The syntax highlighting definition files are located at:

~/.kde/share/apps/katepart/syntax/
/usr/share/kde4/apps/katepart/syntax/

Editing files in the first directory requires root permissions, and the syntax highlighting file will be available to every kate user in your environment. When the directory does not exist, create it in order to place the file.
Find the <language> tag, and modify the extensions attribute, as follows:

<language name="CSS" ... extensions="*.css" ... >
<language name="CSS" ... extensions="*.css;*.less" ... >

Instead of modifying css.xml, I recommend to get the definition file for less css, so that less-syntax is also highlighted correctly. See mtorromeo / kate-syntax-files / less.xml on GitHub.

Copy-paste the following commands, then restart Kate.

mkdir -p ~/.kde/share/apps/katepart/syntax
wget https://raw.github.com/mtorromeo/kate-syntax-files/master/less.xml
Rob W
  • 2,083
  • 2
  • 22
  • 23
  • thanks, i got it already, forgot about this. Actaully you dont need to edit files at all. – wayne Jun 16 '12 at 10:38
  • @wayne You only have to edit files if you want to use existing syntax files for new extensions. But if you use `less.xml`, then there's indeed no need to edit the file. – Rob W Jun 16 '12 at 10:39
  • Hmm? Actually you are wrong you can just type the extensions in there (the options i pointed to in my answer) with a semicolons between them. – wayne Jun 17 '12 at 14:34
  • @wayne The fact that it can *also* be done through the GUI does not invalidate my answer. As for the dates: My answer contained the link to the latest version of the file, the displayed command was an illustration of how to apply the files. – Rob W Jun 17 '12 at 14:47
  • "You only **have to edit files** if you want to use existing syntax files for new extensions. But if you use less.xml, then there's indeed no need to edit the file." That **IS** wrong! I bet you did not know about the option and the fact that you do **not** "have to" edit the files **at all** is right! End if story!I never said it is invalid to say it can also be edited in the files itself. You also said nothing about just an illustration its the latest version from **today** and if someone comes here a year from now he reads "copy paste this" and thats a bad idea to do so.My answer is better! – wayne Jun 17 '12 at 16:35
  • @wayne Updated URL for `wget`. Now, the latest version is downloaded. PS. Q&A is not a contest, no need to be rude. – Rob W Jun 17 '12 at 19:59
  • Next time just not defend your false answers and admit that you are wrong and I will not be "rude". – wayne Jun 18 '12 at 03:02