Notepad++ is an extremely powerful (and free!) text editor. Its find and replace tools can do everything from a simple search and replace in a single file to a regular expression-based search and replace across thousands of files at once. Notepad++ is particularly ideal for quickly editing and changing data in CSV files, but it’s also amazing for editing HTML , CSS , TXT – or any other type of file that can be opened and edited as text.
Comma separated value (CSV) files are a standard way of exchanging data between spreadsheets, databases, and other applications . If you’d like to tweak the data before importing it into another application, Notepad++’s search and replace tools are just the ticket.
Basic Search & Replace
To start performing a search and replace, open the file you want to edit in Notepad++, click the Search menu at the top of the window, and select Find. (You can also press Ctrl+F.) Click the Replace tab, enter your desired text in the Find what and Replace with boxes, and click Replace All.
Although this is a basic, single-document search and replace with no regular expressions, you can customize it quite a bit. For example, if you only want to search and replace for text in part of the file, enable the In selection check box here and select a section of text in the file with your mouse. You can also enable the Match whole word only or Match case check boxes – by default, Notepad++ performs a case-insensitive search and matches all text, whether it’s an entire word or just part of a word.
Search & Replace In Multiple Files
You can easily open multiple documents in Notepad++ – for example, by right-clicking them in Windows Explorer and selecting Edit in Notepad++. Once you have, you can use the Replace All in All Opened Documents button instead of the Replace All button to perform a search and replace in all open documents in Notepad++. Once you’ve performed the search and replace, you can click the File menu and select Save All to save all your opened files with a single click.
If you have a directory full of files you want to perform a search and replace on, you can select the Find in Files tab in the search and replace window (or press Ctrl+Shift+F).
From here, you can specify a directory of files you want to perform a search and replace on . By default, Notepad++ will perform a search and replace on all files in subdirectories under this main directory – uncheck the In all sub-folders check box if you just want to perform a search and replace on the files in the top-level directory. You can also use the Filters box to only perform a search and replace on certain files – for example, you could use the filter *.csv to only perform a search and replace on .csv files or *.csv ; *.txt to perform a search and replace on both .csv and .txt files.
Multi-Line Search & Replace
The dialogs built into Notepad++ have one obvious limitation – they can’t search for a multiple-line section of text and replace it. If you’re replacing a chunk of code with another chunk of code, this can be important. To easily perform a multi-line search and replace, try the ToolBucket plugin. You can install it by clicking the Plugins menu in Notepad++, pointing to Plugin Manager, selecting Show Plugin Manager, clicking the check box next to ToolBucket in the list of available plugins, and clicking Install.
After restarting Notepad++ to enable the plugin, click the Plugins menu, point to ToolBucket, and select Multiline find and replace (or press Alt+Shift+F). Unlike Notepad++’s built-in dialogs, this dialog accepts multiple lines of text.
For more awesome Notepad++ plugins, check out our list of recommended Notepad++ plugins .
Extended Search & Replace
Both the single-file and multiple-file search and replace tools support three different search modes – along with the normal search mode, there’s an extended search mode and one that accepts regular expressions.
In extended mode, Notepad++ will accept some specific escape sequences that match special characters – for example, you can search and replace a line feed, carriage return, or tab character. Here are some of the most commonly used escape sequences:
\n – Line feed character. (End-of-line character on Linux , Mac OS X, and other UNIX-like operating systems.)
\r – Carriage return character. (End-of-line character on Windows.)
\t – Tab character.
For example, if you wanted to replace all the tab characters in a file, you’d specify \t in the Find box. This can be incorporated into a find and replace string with other characters. Remember, to use these escape sequences, you’ll need to enable Extended mode (they also work in Regular Expression mode).
Notepad++ also supports regular expressions. Regular expressions are a powerful tool for advanced users that can match and modify nearly any type of text you can imagine. For example, the regular expression [0-9] will match all characters between 0 and 9. If you have a file with words like test1, test2, and test3, you can perform a search for test[0-9] and the regular expression will match test1, test2, and test3 – but not testb.
A full tutorial on regular expressions wouldn’t fit here, as it would require an entire book. If you want help learning and testing regular expressions, check out RegExr or Rejex, two web-based regular expression tools we’ve covered in the directory. The Notepad++ wiki also contains a tutorial on using regular expressions in Notepad++.
For more awesome Windows software, check out our list of the best Windows software – Notepad++ is on the list!
Do you have any experience using Notepad++’s advanced find and replace tools? Leave a comment and share your knowledge!