Notepad++ Tip: Syntax Highlighting for ASP.NET Files

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..."

screen1
- 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 :

Anonymous said...

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

Matt Blodgett said...

You're welcome, Dave! I'm glad to help. Those Notepad++ settings are definitely not in an obvious place.

Anonymous said...

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.

Anonymous said...

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!

Anonymous said...

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++

Anonymous said...

that last comment from yman was pretty dumb

Anonymous said...

Thanks, just what I needed :)

Anonymous said...

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.

Anonymous said...

Thanks, exactly what I was looking for :)

Anonymous said...

It's awesome, and exatly what I've looking for. Great thanks, Matt.

David Kemp said...

Thanks for posting this

Anonymous said...

Brilliant! Thanks a lot!

Anonymous said...

Good stuff! Your post helped a lot.

Anonymous said...

Very helpful, I looked for a long time and didn't find the setting. Thank you.

AT said...

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.

Unknown said...

Thanks for the tip!

I googled it up today, so sorry for bumping, but I just had to reply!

Johannes said...

Thx Matt, great tips on Notepad++ syntax highlighting!

Karl said...

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!

Anonymous said...

thanks, exactly what I was looking for.

Anonymous said...

You're my hero.

Anonymous said...

Thank you matt!

Jon said...

Worked perfectly!

Anonymous said...

thank you so much. It was such annoying to set color scheme each time I opened ascx files

Gamester said...

thanks,just try it and it works.
btw,found your page when i google for notepad++ syntax highlighting.

Anonymous said...

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...

Anonymous said...

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.

Anonymous said...

Perfect, been searching for this for months

ekestler said...

Positively, absolutely, BRILLIANT!

This should be published on the Notepad++ site!

Unknown said...

ya know...that is in the Notepad++ help files.

? > Help Content
Choose Index tab, and search "languages"

Rob said...

Very good tip! Saves me time whenever I open .NET files in NP++ (which is all the time!)

Jochem Kempe said...

Very nice tip, just what I needed. Thanks!

Charlie Balch said...

Thanks! A very simple solution to my aspx problem with Notepad++.

Anonymous said...

Awesome, ta!

Anonymous said...

ASPX comment delimiters (<%-- --%>) breaks the XML highlighter

Anonymous said...

Thanks Matt, this did the trick, I am loving it!

U DA MA!!!!

artifexmedia said...

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)

Unknown said...

Cheers Fella you saved me so much time on .config files :-D

Anonymous said...

Thanks for sharing this.

JaapGoddijn said...

Thanks a lot, i've been looking for this a long time!

Anonymous said...

Just what I was looking for, thank you.

DJM said...

Just dropping a comment to say thank you. It was as others have stated not where I expected the option to be.

Thank you.

Anonymous said...

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

Anonymous said...

Brilliant, just want i needed!

Eric Developer said...

Amazing!! Thanks man!!

Anonymous said...

This is great. Thanks friend.

Anonymous said...

Awesome tip!!!!!!!!! Thank you!!!

Anonymous said...

Thanks Matt, this is what I've been looking for :)

Dave said...

Thanks for that useful tip.

Unknown said...

Thanks so much! I was trying to figure out how to save my files as aspx... this more than helped!

Mat said...

Thank you for this - very helpful even 4 years later. :)

Sandesh S. Deshmukh said...

Thanks a ton!!

Jim said...

This sounds like exactly what I need, but for some reason didn't work for aspx. Anybody else have that issue?

30mbi said...
This comment has been removed by the author.
30mbi said...

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

Anonymous said...

August 2012, and this is still helping! Thanks Matt!

Aymen said...

4 years later, and this helped me with .config files.

Thanks!

Anonymous said...

It still works. Thank you!

Ben Walsh said...

Brilliant thanks for the tip, you saved me a lot of time!

Anonymous said...

Five years later this is still helping people. Thanks!

Anonymous said...

thanks for ur help

Abdul said...

Nice one.
Thanks.

Unknown said...

thank you for this article!

Unknown said...
This comment has been removed by the author.
Anonymous said...

Thats a cool trick and it worked....

You are Awesome man!!!

mens sana said...

Thanks a lot for sharing (and being accessible via Google...) !
Thumbs up!

Anonymous said...

Thanks a lot for sharing (and being accessible via Google...) !
Thumbs up!

Anonymous said...

April 2014 and its still helpful.
Thumbs up!!

Anonymous said...

April 2014 and its still helpful.
Thumbs up!!

Anonymous said...

Thanks bro, this is gonna help out a lot

Anonymous said...

This has been bothering me for 2 years now (highlight ASPX as HTML). THANKS!!!

Anonymous said...

Very helpful! Thanks a lot for posting.

Anonymous said...

THANX!!!

Anonymous said...

thanks

Anonymous said...

Yes, thank you.

Anonymous said...

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!

Anonymous said...

Pfffft.......and on it goes......Yep Matt, this is still the main solution out there.....sad in a way ;) Thanks!

Anonymous said...

finally, an answer that works! thanks for this.

Anonymous said...

thank you sir! its very effective.

Anonymous said...

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.

Alphons Evers said...

Thanks Matt. This solved my issue.