Notepad++ has a spot in my toolbox mostly because I like it as a lightweight viewer/editor for one-off situations where I really don't feel like loading up Visual Studio just to take a quick peek at a file.
When I first started using Notepad++, one of my common usage patterns was to take a quick look at a file that was part of some solution that I did not currently have open in a Visual Studio instance. I'd just find the file in Windows Explorer, right-click on it, and select "Edit with Notepad++" (which is a context menu addition the Notepad++ installer makes that you'll actually find handy rather than annoying). No long load time, no fuss.
But one of the things I quickly missed that I would have gotten in Visual Studio was syntax highlighting. For example, if I opened a Web.config file in Notepad++, I wouldn't get any syntax highlighting, because Notepad++ didn't know that *.config files are really XML.
The solution to my problem lied in a very obscure Notepad++ setting that took me a lot of digging to find.
Here's what you do:
- On the Notepad++ menu bar, click "Settings" -> "Styler Configurator..."
- Under "Language", select "XML"
- Under "User ext", type in "config". While we're at it, let's also type in (space delimited) "aspx", "ascx", and "master".
- Click "Save & Close"
That's it! Now when you view config files, ASP.NET pages, user controls, or master pages in Notepad++, you'll get syntax highlighting.
80 comments :
Matt,
I agree that Notepad++ is a fantasic tool! I use it for coding python documents, php, html, xml and more. It is my default text editor.
I needed to change the color on some of the highlighting and your Blog helped me find the settings. I looked all over the menus and it was Not where I would expect it.
Thanks again,
Dave from Provo, UT
You're welcome, Dave! I'm glad to help. Those Notepad++ settings are definitely not in an obvious place.
Yo, thanks for the idea. I've been trying to figure out how to get highlighting for rhtml files. With your trick, I have Notepad++ highlighting rhtml like it does html.
Thanks man, I could never figure out how to do this. Every time I opened up a .config file, I would go to Language -> XML... EVERYTIME! What a pain.
You would think that this would be a little bit more intuitive to find.
In any case, nice job!
I use for editing Notepad++ because is a very complex program and support languages like C; C++; Java; C#; XML; HTML; PHP; CSS; makefile ASCII art (.nfo); doxygen ini file and other. Olso you can edit several documents at the same time. I got it from here: Notepad++
that last comment from yman was pretty dumb
Thanks, just what I needed :)
I was searching for this information allover the web. The association with any new extension should be easier than it is now.
This setting is not obvious at all in any of the menues of NotePad+++. Thanks for providing this information.
Thanks, exactly what I was looking for :)
It's awesome, and exatly what I've looking for. Great thanks, Matt.
Thanks for posting this
Brilliant! Thanks a lot!
Good stuff! Your post helped a lot.
Very helpful, I looked for a long time and didn't find the setting. Thank you.
Thanks for the tip!
One quirk I ran into (as of version 5.0.3) is that you must actually close any open files with the new extensions for syntax highlighting to kick in. Simply closing and reopening Notepad++ itself doesn't seem to work.
Thanks for the tip!
I googled it up today, so sorry for bumping, but I just had to reply!
Thx Matt, great tips on Notepad++ syntax highlighting!
Excellent post! Thanks very much Matt, using the Language menu to select my syntax highlighting every single time was starting to get my back up!
thanks, exactly what I was looking for.
You're my hero.
Thank you matt!
Worked perfectly!
thank you so much. It was such annoying to set color scheme each time I opened ascx files
thanks,just try it and it works.
btw,found your page when i google for notepad++ syntax highlighting.
Is it only me that prefers to use the ASP highlighting for ASPX pages, rather than XML? Probably because we've got a lot of pages with tons of crappy inline code...
I prefer it highlighting in asp too. For exactly the same reason. I also actually prefer the hightlighting to VS.
I have also just worked out how to get the auto complete function working for ASP too (notepad++ 5.6.6 supports this). Pretty simple really, just copy a .xml file and a .api file in \Notepad++\plugins\APIs and rename them to asp.api and asp.xml. I used the vb file and combined it with the html file, which means that I get auto completion on my aspx pages now. Most of you probably already know that, but it was a bit of a revelation to me.
Perfect, been searching for this for months
Positively, absolutely, BRILLIANT!
This should be published on the Notepad++ site!
ya know...that is in the Notepad++ help files.
? > Help Content
Choose Index tab, and search "languages"
Very good tip! Saves me time whenever I open .NET files in NP++ (which is all the time!)
Very nice tip, just what I needed. Thanks!
Thanks! A very simple solution to my aspx problem with Notepad++.
Awesome, ta!
ASPX comment delimiters (<%-- --%>) breaks the XML highlighter
Thanks Matt, this did the trick, I am loving it!
U DA MA!!!!
You little ripper!! (That means thanks a billion or so)
This sure beats going Language > HTML or XML!!!!
I am going to do this on all my NP++ installs I have (work, home, laptop etc)
Cheers Fella you saved me so much time on .config files :-D
Thanks for sharing this.
Thanks a lot, i've been looking for this a long time!
Just what I was looking for, thank you.
Just dropping a comment to say thank you. It was as others have stated not where I expected the option to be.
Thank you.
Thanks for the tip! Just what I was looking for. I had just had enough of the Language menu for those damned config files that I open constantly throughout the day
Brilliant, just want i needed!
Amazing!! Thanks man!!
This is great. Thanks friend.
Awesome tip!!!!!!!!! Thank you!!!
Thanks Matt, this is what I've been looking for :)
Thanks for that useful tip.
Thanks so much! I was trying to figure out how to save my files as aspx... this more than helped!
Thank you for this - very helpful even 4 years later. :)
Thanks a ton!!
This sounds like exactly what I need, but for some reason didn't work for aspx. Anybody else have that issue?
that a cool trick but you can also in the menu click on
Language
A
asp
and you have all styling..
including <% directives
Jim - to make it work for described xml settings you have to select in npp : Languages/XML
August 2012, and this is still helping! Thanks Matt!
4 years later, and this helped me with .config files.
Thanks!
It still works. Thank you!
Brilliant thanks for the tip, you saved me a lot of time!
Five years later this is still helping people. Thanks!
thanks for ur help
Nice one.
Thanks.
thank you for this article!
Thats a cool trick and it worked....
You are Awesome man!!!
Thanks a lot for sharing (and being accessible via Google...) !
Thumbs up!
Thanks a lot for sharing (and being accessible via Google...) !
Thumbs up!
April 2014 and its still helpful.
Thumbs up!!
April 2014 and its still helpful.
Thumbs up!!
Thanks bro, this is gonna help out a lot
This has been bothering me for 2 years now (highlight ASPX as HTML). THANKS!!!
Very helpful! Thanks a lot for posting.
THANX!!!
thanks
Yes, thank you.
Thanks, Matt!
Amazing this is still useful considering you posted it almost 7 years ago. Would be nice if it were simply a default syntax config for Notepad++ at this point! But oh, well...
Thanks for saving me the hour+ trying to figure that one out!
Pfffft.......and on it goes......Yep Matt, this is still the main solution out there.....sad in a way ;) Thanks!
finally, an answer that works! thanks for this.
thank you sir! its very effective.
Did not work today. Got latest version of npp. Followed steps outlined above. Closed npp. Opened npp. Opened "login.aspx" and there was no syntax colorization, etc. Did not work for me. Windows 7. VS 2013. npp latest.
Thanks Matt. This solved my issue.
Post a Comment