Tuesday, November 29, 2011

Associate File Extension in Kate Editor


Today, I want to share you how to associate a file extension with some syntax highlighting mode. Normally, you can make it with GUI manner. But sometimes, you will find something strange that you can't using GUI setting. The only solution is modify the file system regarding Kate file association. It's been explained here and here how make that modify. I just want to make the summary of those. For this example, I modify *.do file that by default is associated with Stata script to Tcl script.

1. GUI Way:
  • Inside Kate, chose menu from the toolbar Setting -> Configure Kate... -> Editor Component -> Open/Save -> Modes & Filetypes
  • In MIME type, chose text -> Tcl Script
  • add ;*.do in the File extensions text box
2. File System Modify
  • Edit this file /usr/share/kde4/apps/katepart/syntax
  • In fact, I can't find that file in my computer. What I did then is looking for any suspected files.
~/.kde$ find -name *syntax*
  • this was what I got
./share/config/katesyntaxhighlightingrc
  • from the filename, I strongly suspect that was the file what I expected. And that is exactly what I want. I can now edit that file.
  • Find some *.do word. By default, together with *.ado, that file extension is located under Stata script association. Delete it, as *.do file what I expected should be associated with Tcl script, move that keyword under Tcl script association. Your new setting should be like this.
[Cache /usr/share/kde4/apps/katepart/syntax/tcl.xml] author= extension=*.tcl;*.tk;*.do hidden=false indenter= lastModified=1305932851 license= mimetype=text/x-tcl name=Tcl/Tk priority= section=Scripts style= version=1.10
  • All is done. If your *.do file is still not associated with Tcl script, try to make a new do file, and copy your old do file content to your new file. It seems that the older Kate session still save your previous file setting by temporary.

1 comment: