Sign in to follow this  
Holdit

Colour syntax highlighting for .cfg files

Recommended Posts

I'm sure someone somewhere must have done this already, but I haven't come across it so I thought I'd give it a go.

 

Using NotePad++ (a free download), I've set up a custom language definition for panel.cfg and aircraft.cfg files. All it does is automatically highlight keywords or headings or comments in different colours in an effort to improve the readability of such files when dealing with them as raw text.

 

Examples are probably better than a description...

 

textContext1.jpg

 

textContext2.jpg

 

I've been messing with this for the past hour before it occurred to me that surely I must be doubling up on existing work.

 

Is there already something like this for FSX .cfg files? Is there any demand for it? Feedback would be appreciated, so I can avoid wasting further time on it and go and get the existing alternative...

 

If there isn't anything else out there, I'd be happy to finish this off and make it available for all.

 

 

 

  • Upvote 1

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Nothing in the files themselves is changed - the editor just applies certain rules to how it displays the content.

 

Good question, though, so I've tested it anyway, by opening the default C172 .cfg file, applying the syntax highlighting rule, viewing the results, closing it again, and loading the aircraft into FSX. Note that on closing the file, there was no prompt to save changes, as none were made.

 

The aircraft loaded and flew without any problems.

Share this post


Link to post
Share on other sites

Cool.

 

I'll have a copy of that definition when finished please.

 

cfg files are so easy to get lost in and I already use NP++ for xml because of the formatting it does. I always recommend NP++ for editing xml files for this reason.

 

I don't know of anyone who has done this already.

Share this post


Link to post
Share on other sites

So this must be a set of rules that applies to a certain file type?

 

Just wondering because I once edited an aircraft.cfg with Word and it crashed the sim.

 

I know the FS does not like extra formatting in the config files.

 

regards,

Joe

Share this post


Link to post
Share on other sites

So this must be a set of rules that applies to a certain file type?

 

Just wondering because I once edited an aircraft.cfg with Word and it crashed the sim.

 

I know the FS does not like extra formatting in the config files.

 

 

That doesn't surprise me. Word inserts all kinds of unseen extra stuff that can cause whatever reads the file to throw a hissy fit. That's what text editors are for. Word should never be used for editing any file that will read by the computer. Unfortunately, MS Notepad doesn't seem to have evolved any since the days of Windows 3.1, which is why text editors like NotePad++, and many others, exist. The line numbers feature is a help too.

 

It is possible to set the rules to apply to a particular file extension, but I think .cfg files are used by more applications than FSX, so a better solution is to just load the file, which will appear without any colouring, then click Languages menu and select the FSX type from the list of choices. The colour scheme will then be applied. The keywords etc that I use to define this colour scheme will be unique to FSX, so would probably only serve to confuse if applied to some other kind of .cfg file. Note that this wouldn't do any harm to such files, just make them even harder to make sense of. The computer will still do fine, of course, because it doesn't give a damn about readability anyway - a file or entry is either syntactically correct or it's not, and that's all it cares about.

 

Syntax highlighting is used without any issues for things like batch scripts, programming code, *nix config files etc, none of which respond well to having additional formatting added.

Cool.

 

I'll have a copy of that definition when finished please.

 

cfg files are so easy to get lost in and I already use NP++ for xml because of the formatting it does. I always recommend NP++ for editing xml files for this reason.

 

I don't know of anyone who has done this already.

 

Thanks for the info...I'll finish it off and post it, hopefully before the start of next week.

 

Assuming you are the Ant of Ant's airplanes...love the Trojan. :smile:

Share this post


Link to post
Share on other sites

Thanks Paul

 

Glad you're liking the T28. Should be a new version out soon so keep a look out.

Share this post


Link to post
Share on other sites

Your npp language addon would be nice addition.  Currently I just use the default ms ini language option that breaks out the [...] sections.  I once was looking at doing a keyword highlight for a different format but it looked like it would take a while to figure out how to do that.

 

scott s.

.

Share this post


Link to post
Share on other sites

@Holdit: I don't want to upset you or discourage from what you've started already but if I got you right then all you need to do is to tell N++ thru its style configurator to use INI/INF color settings for CFG files too since they're basically the same syntax-wise.

 

You can later configure or recolor certain elements of INI/INF/CFG syntax to your liking using the same style configurator menu.

 

Sent from my GT-I9295 using Tapatalk

 

 

Share this post


Link to post
Share on other sites

HI Bina,

 

I tried that - I believe in not making unnecessary work for myself, but all it achieved was to highlight the section headings. Nothing wrong with that, but I was looking for something more i.e to improve readability throughout the file.

Share this post


Link to post
Share on other sites

Hi Paul,

 

Yes, I can see the results of your work in original post. Wonderful job! Please keep it up then!!! :)

 

Cheers,

Share this post


Link to post
Share on other sites

great job

Would there be a way to make the orig config files (fsx.cfg) one color and all our tweaks another color, by days edited ,so I could go back and see what I messed up a few days ago

:unsure:  memory challenged

Share this post


Link to post
Share on other sites

great job

Would there be a way to make the orig config files (fsx.cfg) one color and all our tweaks another color, by days edited ,so I could go back and see what I messed up a few days ago

:unsure:  memory challenged

 

I see where you're coming from, but I'm afraid not - it's beyond the scope of what syntax highlighting does. Although there's nothing to stop you maintaining a change history at the top of the file in the form of comments, and you can also comment any changes in the main body of the file.

 

I use the "Save as" function to make a backup before tweaking, that way I can always backtrack if things go wrong, e.g. "fsx_orig.cfg" or "fsx_131118.cfg". I know this deals with the whole file rather than individual edits, but if you use something like WinDiff, it'll tell you exactly what the differences are between versions.

 

Thanks for the memory jog about fsx.cfg, though. I'll see about incorporating that also.

Share this post


Link to post
Share on other sites

Hi Paul,

 

Yes, I can see the results of your work in original post. Wonderful job! Please keep it up then!!! :)

 

Cheers,

 

Thanks, glad you like it.

 

I had hoped to do the colouring by theme, e.g. aircraft.cfg control surface entries to have their own colour engine entries to have another, but I don't have enough colour slots to play with, any in any case most of the colours in the palette are too subtle to be useful. What I'm going for now is a colour for each block of entries until I run out, then start with the first colour again. At least this way each text block will be different from its neighbors and far enough away from a similarly-coloured block.

 

I just hope this thing doesn't limit the number of keywords I can define...

 

:smile:

Share this post


Link to post
Share on other sites

Are you playing with N++ internal color palette from within Style Configurator, or writing an extetnal plugin for it?

 

Sent from my GT-I9295 using Tapatalk

 

Share this post


Link to post
Share on other sites

Just playing with the style configurator. I wouldn't know where to start writing a plugin.

Share this post


Link to post
Share on other sites

I ended up opting for four different definitions, it was actually easier to do it that way:

  • aicraft.cfg
  • fsx.cfg
  • panel.cfg
  • scenery.cfg

 

I'd prefer to have a couple of people check these out before I upload them to the file library, so please PM me, anyone who'd like to participate in a quick and dirty beta test.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this