10

Often I have to open header-files (with ending .h) in Kate. The default syntax-highlighting with which these files will be opened is always C++. How could this be changed to Fortran so that I don't have to switch manually?

Edit1:

I already added a *.h; to the list of extensions in fortran.xml under

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

but this doesn't help. *.h; is also included in several other XML-files in the upper directory.

By the way: The priority in both files cpp.xml and fortran.xml is 9.

Edit2:

I tested the modifications on the XML-files always by restarting Kate with the same files. Here, I see no changes. But, if I close an re-open the same files, it works.

Chrispie
  • 3,613
  • 2
  • 13
  • 16

2 Answers2

11

Kate is using now ~/.kde/share/config/katemoderc

  1. From GUI: Kate menu → Settings → Configure Kate... → Editor Component → Open/Save → Modes & Filetypes

  2. Select filetype: Sources/Fortran, add ;*.h to file extensions, raise priority from 9 to 15 (Should be ok, Max priority for .h was in Sources/C++ which is 9)

    adding .h to fortran mode

  3. Close then reopen the files.

user.dz
  • 1,835
  • 16
  • 31
  • 3
    As of katepart5, kate is using ~/.local/share/katepart5 – Datalore Feb 02 '15 at 00:38
  • 1
    Once again, for Kate 3.10.5 the config file is different. That's a good reason to always make these sorts of changes through the GUI Menu. – Octopus Sep 15 '15 at 18:53
  • After making any such change to the highlighting settings, it seems necessary to close the files and reopen them for the highlighting to work. – Octopus Sep 15 '15 at 18:54
  • @Octopus, thank you, I added that step. Me too, I hate when they change the same thing in successive releases. It makes its administration too hard. – user.dz Sep 15 '15 at 20:48
  • What 's the meaning of the priority number? What does changing it accomplish? You'd have to have a list of current priorities for other filetypes to know what's the best setting, right? – Bennypr0fane May 19 '19 at 13:27
  • 1
    @Bennypr0fane , The higher priority number is the one used in case same extension is supported by multiple syntax-highlighting. The OP was having C++ highlighting applied on `.h` header files, so we raise the priority of Fortran highlighting to be applied instead. Well yes, but it takes time to check each through GUI one by one, so best is to open the configuration file directly `katemoderc`. I didn't use KDE for while, so configuration format, path & filename may be changed in late releases. Check the other answer here https://unix.stackexchange.com/a/410519/12209 . – user.dz May 19 '19 at 17:47
2

For kate 17.04.3 the directory of syntax is ~/.local/share/org.kde.syntax-highlighting/syntax

roaima
  • 107,089
  • 14
  • 139
  • 261
  • Why has this answer been downvoted? Arek is right. [See this](https://kate-editor.org/2016/11/15/ksyntaxhighlighting-a-new-syntax-highlighting-framework/) – Primo Petri Apr 06 '18 at 16:17