A Few Notepad++ Tips

Like many software developers that have a Windows PC, I use Notepad++ as my text editor on that platform. I recently spent some time getting to know it better, and I thought that I would turn what I learnt into a blog post.

Viewing Content

Sometimes you need to be able to see the content of two files at once. To do this, open the files in Notepad++, right-click one of the tabs and select the Move to Other View option.


You can make the split a horizontal rather than a vertical view split by right-clicking on the split handle and selecting one of the two rotate options. You can also synchronize the scrolling of the two views by using the View > Synchronize Vertical Scrolling and View > Synchronize Horizontal Scrolling menu options.

You can use this feature to view a file side-by-side with itself. This is useful if you need to make changes to one part of a file based on content that is in another part of the same file. Just right-click the file’s tab and select the Clone to Other View option.

Hiding Content

As you will be aware, Notepad++ implements code folding in source code files. This feature allows you to hide and show the contents of programming structures like functions and namespaces. But what you might not know is that Notepad++ also includes options for hiding arbitrary content.

The simplest way to do this is with the Hide Lines feature. Just select the lines you want to hide and then click the View > Hide Lines menu option. The selected text gets replaced by a couple of arrows which you can click on to restore the text.


The more advanced hiding options are available through the TextFX plug-in that comes bundled with Notepad++. Included in it is a set of commands that are grouped under the submenu TextFX Viz. (The name ‘Viz’ simply refers to what these commands do: they hide and show content.) There is also a TextFX Viz Settings submenu that contains various settings to control how the Viz commands work; just click on a setting to toggle it on (ticked) or off.

One group of Viz commands enables you to hide and show lines based on the current clipboard content. For example, to hide all lines that contain the word ‘rabbit’, perform the following steps:

  1. Highlight the word ‘rabbit’ somewhere in the document and press Ctrl-C to copy it to the clipboard.
  2. Press Ctrl-A to select all content.
  3. Select the TextFX > TextFX Viz > Hide Lines with (Clipboard) text menu option.

All the matching lines are now hidden. Breaks in the line numbering at the side of the document show you where there is hidden content. To make the lines visible again, select the TextFX > TextFX Viz > Show Between-Selected or All-Reset Lines menu option.

You can also make TextFX treat the string in the clipboard as a regex. To enter this mode, just tick the TextFX > TextFX Viz Settings > +Viz Text Search Regex menu option.

Selecting Content

A common need is to be able to select particular lines in a file and then perform some action on them, such as copying or deleting them. There are multiple ways to do this in Notepad++.

In the previous section, I introduced the TextFX Viz commands and demonstrated how you can hide lines based on the current content of the clipboard. The TextFX Viz submenu also includes a group of commands for copying, cutting, or deleting the hidden or visible content of a file. This is an approach that Paul Lockwood takes to delete particular content in a log4net log file. Note that the TextFX > TextFX Viz > Delete Invisible Selection menu option clears the content of the invisible lines rather than deleting them. As demonstrated in Paul’s post, you can use the TextFX > TextFX Edit > Delete Blank Lines menu option to then delete those cleared lines.

An alternative approach to selecting content is to use the Mark dialog. You use it to bookmark the lines you want to select, allowing you to then run commands on just those bookmarked lines. The process is as follows:

  1. Click the Search > Find menu option and then click the Mark tab.
  2. Tick the Bookmark line option, select the Regular expression option, and then enter your regex.
  3. Click the Mark All button and then click on OK in the result dialog.

Note that your regex does not need to match the whole line, only the text of interest in it. Also, if the Purge for each search option in the Mark dialog is not ticked, you can accumulate bookmarks from multiple regexes.

Once you have added your bookmarks, you can use the commands in the Search > Bookmark submenu to process them. For example, to delete the bookmarked lines, click the Search > Bookmark > Remove Bookmarked Lines menu option.

A quirk of the Mark dialog is that it is used to both mark and bookmark text, where marking is the highlighting of the matched text. To clear all bookmarks you can use the Search > Bookmark > Clear all Bookmarks menu option. To clear all marks you can either click on the Clear all marks button in the Mark dialog box, or you can use the Search > Unmark All > Clear all Styles menu option.

Searching Content

Like many text editors, Notepad++ offers a regex option in its find and replace dialogs. However, you should be aware that the regex implementation in Notepad++ lacks support for some useful POSIX regex features:

  • The interval operator ({min,max}) is not supported.
  • The alternation operator (|) is not supported.
  • A given pattern cannot have quantifiers applied to it, e.g., you cannot use (foo)+ to match one or more repeats of the pattern foo.

Extending Notepad++

Notepad++ can be extended through a plug-in mechanism. It comes with a number of useful plug-ins, such as the TextFX plug-in used earlier in this post, but there are many more available. A simple way to discover and install Notepad++ plug-ins is to use the Plugin Manager component. To open it, click on the Plugins > Plugin Manager > Show Plugin Manager menu option.

There are two plug-ins that you may find of particular interest: Document Monitor and XML Tools.

If you install and activate the Document Monitor plug-in, it will monitor the currently open files for external changes every three seconds, and if necessary update those files in Notepad++ to reflect any changes. This is useful when viewing log files that are still being written to. Note that the plug-in will move the file view to the end of the file when it updates.

The XML Tools plug-in consists of a useful set of XML-related tools. You can verify and validate XML, reformat it, comment and uncomment sections, and more besides.


I hope that you have found this information useful and that Notepad++ will continue to be your ‘go to’ tool for text editing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s