[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ktexteditor-devel
Subject:    Re: Automatic syntax colouring in Kate
From:       Anders Lund <anders () alweb ! dk>
Date:       2005-11-29 20:05:12
Message-ID: 200511292105.15243.anders () alweb ! dk
[Download RAW message or body]

On Tuesday 29 November 2005 12:21, Com MN PG P E B Consultant 3 wrote:
> I like the syntax colouring in Kate. It would be, however, convenient,
> if
> Kate could recognize by itself, how to choose syntax highlighting, when
> opening a file.
>
> Emacs for example, deduces the highlight mode by inspecting the first
> line.
> If it contains a certain string (easily embeddable inside a comment),
> such
> as -*- bash -*-, emacs uses syntax highlighting for bash. If there is no
> such
> string, but a #! line, it uses this information to turn on syntax
> highlighting.
>
> I don't know whether this is possible with Kate too.
>
> I'm using Kate 2.1 on RedHat 3.1.3.
>
> Ronald

As Dominik already told you, Kate does support it's own format for modelines.

A little more on how kate decides which syntax highlight to use for a file:

The syntax highlights are defined in XML files, residing in 
KDEDIR/share/apps/katepart/syntax. Each file contains a list of mime types 
and filename masks for the files that it think should use it, and a priority 
level. When you open a file in kate, it first use the mimetype detection 
system in KDE to and tries to find the syntax highlight with the highest 
priority supoprting the mimetype. Then the filename mask is tried.

It is also possible to define a 'file type' in kates configuration, which can 
apply a syntax highlight to files with a certain mimetype or filename match. 
Those definitions are given a higher priority than the standard detection 
using mimetypes.

You can also use a modeline in your files, in the top or bottom 10 lines, with 
the syntax as described by Dominik: 'kate: <key> <value>;', for example 'kate 
hl HLName;' Or you can put such a modeline in a file named .kateconfig in the 
directory where you keep your files (given you use the kate application).

Finally, the properties of the individual highlights can be edited in the 
configuration, in the highlight page: you can edit the priority, mimetypes 
and filename masks of each highlight.

-anders
-- 
www: http://alweb.dk
jabber: anderslund@jabber.dk
_______________________________________________
Ktexteditor-devel mailing list
Ktexteditor-devel@kde.org
https://mail.kde.org/mailman/listinfo/ktexteditor-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic