nedit-ng icon indicating copy to clipboard operation
nedit-ng copied to clipboard

adjusting syntax highlighting for plain text files

Open lester96 opened this issue 4 years ago • 6 comments

When nedit doesn't know what kind of file it is opening, it opens it as a plain text file. But I can't find a way to set the syntax highlighting for this kind of file. It doesn't show up in recognition patterns as a language mode, so there is not a way to change what the default is. What I would really like to do is turn off backlighting by default for plain text files. I can create a "Plain" text mode, but it does not get selected by default. This behavior is the same as default nedit, so I guess this is an enhancement.

lester96 avatar Jan 01 '20 22:01 lester96

Yup, definitely an enhancement, but a seemingly reasonable one. I'll check it out :-)

eteran avatar Jan 02 '20 00:01 eteran

I have similar issue as I want to create a macro that would be available for Perl and Plain files, but that is not possible. I even added a new language Text to languages.yaml file

---
name: Text
regex: .*

but it looks like the regex has preference over extension setting and thus all files that are recognized by regex (why not empty files?) will become of type Text no matter what the file extension is. This is how it works also in old nedit, but at least I think that the file extension should rule the language and regex should be used if extension does not match with any language definitions.

marilmanen avatar Jan 16 '20 05:01 marilmanen

@marilmanen when you add that to the languages.yaml file, did you put it at the very end? I believe that they are processed in order and the first match wins. So you'd almost certainly want to place that last.

eteran avatar Jan 17 '20 13:01 eteran

Ahh, I see, yes regex testing definitely is done before extensions. Really, what we need to do is have first-class support for specifying these things for plain text files. I'll look into what the best way to add that would be.

eteran avatar Jan 17 '20 13:01 eteran

While you're looking at this area… I have a common use case where I would like to use a regex on the filename for language recognition because these files have a name prefix, not a suffix (e.g. Makefile.in). There's no way to configure that with the currently available controls, so every time I edit these kinds of files I have to manually set their language.

anjohnson avatar Jan 17 '20 16:01 anjohnson

Will do

eteran avatar Jan 17 '20 18:01 eteran