Page 1 of 1

Specifying syntax for hosts file

Posted: Mon Dec 30, 2019 11:34 pm
by senpai71
I'm trying to see whether it's possible to define a syntax file for the hosts file (C:\Windows\System32\drivers\etc\hosts).

Since the file doesn't have a suffix, I created a new syntax file (hosts.syn) with the following:

SingleComment = #

If I open the hosts file and manually set it to use this syntax file, it works, and commented-out lines display differently.

But I can't seem to create a document class which only applies to hosts - creating a new class and specifying "Files in class hosts" as simply "hosts" doesn't work.

Image

Anyone got any great ideas?

Posted: Tue Dec 31, 2019 4:20 pm
by MudGuard
IIRC the trick is to use "hosts." as Files in class pattern.
The dot was important ...

Posted: Tue Dec 31, 2019 4:26 pm
by MudGuard
Also check whether another document class fits the file name - in my textpad, the text document class matches for "*.".
IIRC the classes are checked from bottom to top - first hit wins ...
(and I don't see any chance to change the order ...)

Posted: Tue Dec 31, 2019 4:42 pm
by ben_josephs
The dot in the filename is not required.

As MudGuard suggests, you can remove the entry:
Configure | Preferences... | Document Classes | Text | Files in class | *.

Alternatively, you can give the class a name, for example, ~ hosts, that places it lexicographically after all the other classes.

Posted: Thu Jan 02, 2020 9:59 pm
by senpai71
Thanks @ben_josephs and @MudGuard - I simply removed the *. entry from the TXT class, and it's all working fine.