Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ : Custom Syntax Highlighting for .txt files

I keep code samples that I find useful as text files on my computer. I store them as txt files as opposed to the language in which they are written, so that they will open in Notepad++ instead of the editor (i.e. I don't want my c++ examples to open in an IDE, just Notepad).

Is there a way I can have Notepad++ apply appropriate syntax highlighting to the text file by reading a special code in the text file itself?

For example if I had some sql, the first line of the text file could read like this:

##Language=SQL 

... my sql code properly highlighted as sql ...

Thanks in advance. I realize I could just choose the language after opening the file (i.e. Language > SQL), but it would be much more convenient if it could do it automatically.

like image 402
jj. Avatar asked Dec 09 '09 23:12

jj.


1 Answers

No, it can't. You can choose it manually or use special file type extensions which you then associate with Notepad++ and tell it to highlight the files as the appropriate language.

For example, use .txtsql files for SQL, .txtcpp files for C++ and so on.

like image 90
Maximilian Mayerl Avatar answered Oct 11 '22 14:10

Maximilian Mayerl