Thoughts about software development and other things
Wednesday, 26 October 2011
Some things I didn't know about Notepad++
Notepad++ has been my text editor of choice for a number of years now. It's got a lot more features now than when I first started using it. I've not really kept track of the additions so I thought it was about time had a good look to see what's available that I've missed. A quick Google search found a lot of useful tips. I stole a few tips from various blogs which I've linked to at the bottom of this post.
Regular expression search and replace with groups
Okay, this isn't new to me, but it's definitely worth mentioning. Search and replace using regular expressions is extremely useful, even more so when using groups. Different regular expression engines use different syntax for groups, in Notepad++ it's slash and a number.
Here's a stupid example. Say I wanted to add a full stop at the end of each line:
Find what: ^(.*)$
Replace with: \1.
TextFX and Plugins menus
There's all kinds of wonder hidden in these menus. A few of my favourites are:
Plugins -> Compare (Alt + D) - Compares two files
TextFX Convert -> HTML Encode
TextFX Characters -> Proper Case - E.g. "cloud moon goat" becomes "Cloud Moon Goat". Also has upper and lower case options (which are more easily available if you right click in a document)
TextFX Tools -> Delete line number or first word
TextFX Settings -> Auto close XML/HTML tags
Custom file extensions
Notepad++ provides highlighting for many different types of file, but misses common file types that I use such as .build and .config. Turns out it's very easy to map custom file extensions. Select Settings -> Style Configurator, then choose the required language and add a space separated list of extensions in the "User ext" box.
I was surprised to find out this is exactly the same as Visual Studio. Hold Alt, click and drag to select a column.
Macros are something I've never bothered to look into. I assumed they just recorded basic text manipulation (typing, copy, paste, etc.), but turns out they can record more than that. For example you can save search and replace actions which is great for saving any common search and replace operations with complex regular expressions.
Here's a few other bits and pieces that I thought were worth mentioning: