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.
Matt,
ReplyDeleteI 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.
ReplyDeleteYo, 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.
ReplyDeleteThanks 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.
ReplyDeleteYou 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++
ReplyDeletethat last comment from yman was pretty dumb
ReplyDeleteThanks, just what I needed :)
ReplyDeleteI was searching for this information allover the web. The association with any new extension should be easier than it is now.
ReplyDeleteThis 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 :)
ReplyDeleteIt's awesome, and exatly what I've looking for. Great thanks, Matt.
ReplyDeleteThanks for posting this
ReplyDeleteBrilliant! Thanks a lot!
ReplyDeleteGood stuff! Your post helped a lot.
ReplyDeleteVery helpful, I looked for a long time and didn't find the setting. Thank you.
ReplyDeleteThanks for the tip!
ReplyDeleteOne 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!
ReplyDeleteI googled it up today, so sorry for bumping, but I just had to reply!
Thx Matt, great tips on Notepad++ syntax highlighting!
ReplyDeleteExcellent post! Thanks very much Matt, using the Language menu to select my syntax highlighting every single time was starting to get my back up!
ReplyDeletethanks, exactly what I was looking for.
ReplyDeleteYou're my hero.
ReplyDeleteThank you matt!
ReplyDeleteWorked perfectly!
ReplyDeletethank you so much. It was such annoying to set color scheme each time I opened ascx files
ReplyDeletethanks,just try it and it works.
ReplyDeletebtw,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...
ReplyDeleteI prefer it highlighting in asp too. For exactly the same reason. I also actually prefer the hightlighting to VS.
ReplyDeleteI 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
ReplyDeletePositively, absolutely, BRILLIANT!
ReplyDeleteThis should be published on the Notepad++ site!
ya know...that is in the Notepad++ help files.
ReplyDelete? > 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!)
ReplyDeleteVery nice tip, just what I needed. Thanks!
ReplyDeleteThanks! A very simple solution to my aspx problem with Notepad++.
ReplyDeleteAwesome, ta!
ReplyDeleteASPX comment delimiters (<%-- --%>) breaks the XML highlighter
ReplyDeleteThanks Matt, this did the trick, I am loving it!
ReplyDeleteU DA MA!!!!
You little ripper!! (That means thanks a billion or so)
ReplyDeleteThis 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
ReplyDeleteThanks for sharing this.
ReplyDeleteThanks a lot, i've been looking for this a long time!
ReplyDeleteJust what I was looking for, thank you.
ReplyDeleteJust dropping a comment to say thank you. It was as others have stated not where I expected the option to be.
ReplyDeleteThank 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
ReplyDeleteBrilliant, just want i needed!
ReplyDeleteAmazing!! Thanks man!!
ReplyDeleteThis is great. Thanks friend.
ReplyDeleteAwesome tip!!!!!!!!! Thank you!!!
ReplyDeleteThanks Matt, this is what I've been looking for :)
ReplyDeleteThanks for that useful tip.
ReplyDeleteThanks so much! I was trying to figure out how to save my files as aspx... this more than helped!
ReplyDeleteThank you for this - very helpful even 4 years later. :)
ReplyDeleteThanks a ton!!
ReplyDeleteThis sounds like exactly what I need, but for some reason didn't work for aspx. Anybody else have that issue?
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethat a cool trick but you can also in the menu click on
ReplyDeleteLanguage
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!
ReplyDelete4 years later, and this helped me with .config files.
ReplyDeleteThanks!
It still works. Thank you!
ReplyDeleteBrilliant thanks for the tip, you saved me a lot of time!
ReplyDeleteFive years later this is still helping people. Thanks!
ReplyDeletethanks for ur help
ReplyDeleteNice one.
ReplyDeleteThanks.
thank you for this article!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThats a cool trick and it worked....
ReplyDeleteYou are Awesome man!!!
Thanks a lot for sharing (and being accessible via Google...) !
ReplyDeleteThumbs up!
Thanks a lot for sharing (and being accessible via Google...) !
ReplyDeleteThumbs up!
April 2014 and its still helpful.
ReplyDeleteThumbs up!!
April 2014 and its still helpful.
ReplyDeleteThumbs up!!
Thanks bro, this is gonna help out a lot
ReplyDeleteThis has been bothering me for 2 years now (highlight ASPX as HTML). THANKS!!!
ReplyDeleteVery helpful! Thanks a lot for posting.
ReplyDeleteTHANX!!!
ReplyDeletethanks
ReplyDeleteYes, thank you.
ReplyDeleteThanks, Matt!
ReplyDeleteAmazing 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!
ReplyDeletefinally, an answer that works! thanks for this.
ReplyDeletethank you sir! its very effective.
ReplyDeleteDid 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.
ReplyDeleteThanks Matt. This solved my issue.
ReplyDelete