Notepad++ tips and tutorials

Notepad++ can do more than open and save a text file. These 10 tutorials cover the tasks that come up most often: removing duplicate lines, comparing files, auto-completing HTML tags, batch-editing with regex, and more.

ADVERTISEMENT

What is Notepad++?

Notepad++ is a free text and code editor for Windows.

Remove duplicate lines in Notepad++

This works on any file type: TXT, HTML, XML, and more.

  1. Click Edit in the top menu.
  2. Go to Line Operations.
  3. Click Remove Duplicate Lines.
    Remove duplicate lines in Notepad++
ADVERTISEMENT

Auto-complete HTML tags in Notepad++

  1. Click Settings in the top menu.
  2. Click Preferences.
  3. Click Auto-Completion.
  4. Check the html/xml close tag option.
    Auto-complete HTML tags in Notepad++
  5. Click Close at the bottom of the window.

HTML tags now close automatically. If they do not, restart Notepad++.

Compare files in Notepad++

  1. Click Plugins in the top menu.
  2. Click Plugins Admin.
  3. Type compare in the search field.
  4. Select the Compare plugin.
  5. Click Install.
    Install the Compare plugin in Notepad++
  6. Click Yes.
  7. Wait for Notepad++ to restart. Then open the two files you want to compare.
  8. Click Plugins in the top menu.
  9. Go to Compare and then click Compare.
    Compare files in Notepad++

View files side by side in Notepad++

Method 1

  1. Right-click on the tab of a file.
  2. Go to Move Document.
  3. Click Move to Other View.
    View files side by side in Notepad++

Method 2

  1. Click View in the top menu.
  2. Go to Move/Clone Current Document.
  3. Click Move to Other View.
    View files side by side in Notepad++

Open a file in a new window in Notepad++

Method 1

  1. Right-click on the tab of the file.
  2. Go to Move Document.
  3. Click Open in New Instance.
    Open a file in a new window in Notepad++

Method 2

  1. Click View in the top menu.
  2. Go to Move/Clone Current Document.
  3. Click Open in New Instance.
    Open a file in a new window in Notepad++

Remove plugins from Notepad++

  1. Click Plugins in the top menu.
  2. Click Plugins Admin.
    Notepad++ plugins admin
  3. Click Installed.
  4. Select the plugin you want to remove.
  5. Click Remove.
    Remove plugin from Notepad++
  6. Click Yes.

Add a word to the beginning or end of each line in Notepad++

  1. Press Ctrl + H to open the "Replace" window.
  2. Choose Regular expression at the bottom of the window.
  3. Type ^ in the Find what field to add the word to the start of each line. Type $ in the Find what field to add it to the end.
  4. Type the word in the Replace with field. Add a space after or before your word if you want it separated from the existing text.
  5. Click anywhere in the file first.
  6. Click the Replace All button.
    Add a word to the beginning or end of each line in Notepad++

View how many files are open in Notepad++

  1. Click Window in the top menu.
  2. Click Windows.
  3. The count appears at the top of the list.
    View how many files are open in Notepad++

Remove empty lines in Notepad++

  1. Click Edit in the top menu.
  2. Go to Line Operations.
  3. Click Remove Empty Lines.
    Remove empty lines in Notepad++

Duplicate a value into a new field in all open files in Notepad++

Use Replace with a regular expression to copy the value from title: into a new h1: line (or description: into intro:) across every open file at once. Files that already have the new field are skipped automatically. This example uses Hugo frontmatter (the metadata block at the top of a content file), but the same trick works for any repeated text pattern: CSV headers, config keys, log lines, whatever you need to duplicate across files.

  1. Make sure all the files you want to edit are open in Notepad++.
  2. Press Ctrl + H to open the Replace window.
  3. Choose Regular expression at the bottom of the window. This lets you use special patterns to match and copy parts of a line.
  4. In the Find what field, type:
    (?m)^(title:\s*(.*))$(?!\r?\nh1:)

This matches the title: line, grabs its value, and skips the file if h1: already sits on the next line.

  1. In the Replace with field, type:
    $1\r\nh1: $2

$1 is the original title: line. $2 is just the value after title:. \r\n adds a new line between them.

  1. Click Replace All in All Opened Documents.
Duplicate a value into a new field in all open files in Notepad++

The title: → h1: run above is one example. The same structure works for any field. To copy description: into intro: instead, use:

  • Find what: (?m)^(description:\s*(.*))$(?!\r?\nintro:)
  • Replace with: $1\r\nintro: $2

To confirm which files already had the field before you ran the search and replace, press Ctrl + Shift + F to open "Find in Files", type (?m)^h1: in Find what, and click Find All. The results panel lists every file that already contained h1:.

ADVERTISEMENT