0

How can you add custom syntax highlighting for a plaintext file? (for any filetype, not just txt)

I leave this question open to any editor for those who know - I'm not picky. If you want me to be specific, assume Sublime Text 2 or 3. (I write a lot of things in Sublime Text, I use many IDEs regularly, I used to use Notepad++.)

Sometimes I want to be able to write up notes in a file, but it would be helpful to have my own custom syntax highlighting for plaintext notes.

Is there a way to do this?

I would also consider an alternative file extension as a valid answer (like .yml)

What I'm looking for is a way to color "*", ">", "-", digits, etc. in a plaintext file (of any file type).

There are many ways to state this question, and I'm not finding anybody asking it.

Thanks!

EDIT:

I realize that a solution would be to have access to the Sublime Text files that define the syntax highlighting grammars. Does anyone know where those would be, so that I could examine them and make my own? (Your own grammar is not for the lay person, I know)

  • That's easy copy paste, and I found those. They're saying "no-NP++ can't" in the answers, which as a dev, I am aware of. Sublime has some ability to configure it's large language support. I'm essentially wondering if I can access the files that define the grammar for each syntax and make my own. – Plasmarob Apr 23 '15 at 20:42
  • The accepted answer in the second link leads here, which shows you how to set up a custom syntax highlighting scheme. Also the Language menu allows you to create a user-defined language and apply its highlighting rules to any file including text files. So how is that equivalent to "no NP++ can't"? – Karan Apr 23 '15 at 20:51
  • See top answer in the first link. Why is there no currently existing (non-archived) copy of that document if the process is still supported in Notepad++? Or is it no longer supported? (I'm going to have to look this up further when I have time) I'm looking to add a grammar to a set, not reinvent the wheel. – Plasmarob Apr 23 '15 at 20:57
  • 1
    Wiki page may have been deleted for a variety of reasons, or moved elsewhere. Doesn't mean feature's gone. NP++ > Language menu > Define your language shows this. – Karan Apr 23 '15 at 21:04
0

I think this might be the answer to my question:

http://docs.sublimetext.info/en/latest/reference/syntaxdefs.html?highlight=syntax

However, it's not completely transparent how you would add a new one.

A good answer is here:

https://stackoverflow.com/questions/15646926/sublime-text-how-to-customize-syntax-highlighting

The answer is .tmTheme files as per this topic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.