Monday, December 7, 2009

Notepad++ is probably the best text editor for Windows - and it's FREE. It has a huge range of features for working with text files, scripts, HTML files, etc. Here are some pointers on just a few of those features.

1. Set Language to match your code
One very nice feature of Notepad++ is the ability to color pieces of code. This is very useful when writing C, SQL, HTML or other types of files, allowing you to easily visually distinguish between functions, reserved words, comments, text, and other types of symbols and expressions in your code.

Notepad++ will automatically detect your code based upon the language selected. You can specify the language yourself or Notepad++ will set it based on the file extension.

HTML as text before specifying language.

HTML code after specifying language.

2. Bulk find & replace
If you want to replace a certain entry in your file(s), Notepad++ is the ticket. Not only can it instantly search through all entries in a file, it can search all open files or even all files in a directory (including sub-directories), including, matching only certain file types.

3. Search and replace using regular expressions
When it comes to finding what you want, Notepad++ is not limited to mere words. You can also use powerful regular expression to match dynamic entries. For example, the below search will find (and replace) all tags in the source of HTML files, regardless of the actual image size specified:

Of course, some knowledge of regular expressions is required to use this feature. Not surprisingly, these regular expressions will also serve you well if you dabble in the Linux command line with sed or awk commands.

4. Tidy HTML code

If you're writing web articles, there's a fair chance your code will include a bit of unnecessary breaks, misaligned tags and so forth. Notepad++ can Tidy your HTML code.
For example, here is some unformatted text:

Which we want to format with HTML:

5. Save all open files
While this may not sound too exciting, imagine you have several open files - Notepad++ behaves like Firefox in this regard and opens documents in tabs - each one changed after you ran a bulk find & replace earlier. Saving them one by one can be tedious. Notepad++ saves you the hassle. You can save all open files at once.

Similarly, you can close them all at once.

Conclusion

Notepad++ is an extremely powerful and useful tool. We only scratched the surface on its features. With Notepad++ you can use macros or function completion, compare documents, export files to other formats, and a whole lot more.