Back to article
Getting Started With the Kate Text Editor: Kate For Coders
April 1, 2009
In the last two articles (part 1, part 2), I looked at getting started with Kate, and then at some of the more advanced features and configuration options. This final article covers features that you may find useful if you regularly write code or markup.
Syntax highlighting automatically colours different words and lines in your file according to their function. So comments will be shown in a different colour from the main code, quoted strings in a different colour again, and so on. It's incredibly useful if you work with any kind of programming, scripting, or markup language.
Kate's predefined syntax highlighting settings cover the vast majority of programming/scripting languages and markup languages, as well as some configuration file types, diff, LDIF and MySQL, and several assembler types. When you open a file, Kate will attempt to automatically detect and apply the appropriate highlighting setting, or you can apply a setting from the Tools->Highlighting menu.
Just in case your preferred language isn't one of the many provided, you can also define your own syntax highlightings, or if you want to vary the ones that are provided, there's scope for that too. Kate's syntax highlighting rules are XML files containing rules for detecting text, keyword lists, and style definitions: to change the behaviour, edit these files.
The Kate syntax highlighting system aims to use the same colours for the same/similar formats across languages, making them easier for you to understand intuitively. It does this by having a set of default styles (e.g. dsNormal, for normal text, dsComment, and dsError) which are used for these sections of the file. This also makes it easier for you to generate your own styles, should you need to.
If you spend a lot of time typing, it's useful to be able to navigate around a file without having to move your hand to the mouse. Unfortunately, Kate doesn't seem to have any keyboard navigation shortcuts, as far as I could tell, or to support the standard readline ones (e.g. Ctrl-A for beginning of line). Navigation is entirely with arrow keys, and Ctrl-arrow to move a word at a time. This isn't uncommon in graphical text editors, but if you're used to the extensive keyboard navigation options of editors like emacs and vi(m), it can feel a bit clunky.
One nice touch is that using Ctrl + the up/down arrows scrolls the file without moving the insert point – so you can go check a function definition or anything else elsewhere in your file without losing where you're editing.