Notepad++ Tips & Tricks

Default location where Notepad++ config is stored:

  • %appdata%\Notepad++
  • Which resolves to c:\users\raj\AppData\Roaming\Notepad++

Regex documentation:

Config files:

  • config.xml
  • contextMenu.xml
  • langs.xml
  • shortcuts.xml
  • styler.xml

Important Plug-ins

  • NppCrypt
  • TextFX
  • DSpellCheck
  • Emmet

Important Shortcuts:

  • Ctrl+F3: Select and Find next
  • Ctrl+F2: Toggle bookmarks
  • F2: Next bookmark
  • Shift+F2: Previous bookmark
  • F7: Open Search result window

Tip - Regex: Prefix all lines with a string

Before:

1
2
google.com
yahoo.com

After:

1
2
http://www.google.com
http://www.yahoo.com

Find and Replace Options:

1
2
3
Find What: ^
Replace with: http://www.
Search Mode: Select Regular expression radio button

Tip - Regex: Suffix all lines with a string

Before:

1
2
www.google
www.yahoo

After:

1
2
www.google.com
www.yahoo.com

Find and Replace Options:

1
2
3
Find What: $
Replace with: http://www.
Search Mode: Select Regular expression radio button

Tip - Replace multiple space around a operator with single space

1
2
Find what: \s*:\s*
Replace with: \x20:\x20

Tip - Regex: Remove all lines with word “hello” in it

1
2
Find what: .*hello.*
Replace with: Nothing

Tip - Regex:

Before:

1
var str = document.getElementById("UserName").value

After:

1
"UserName").value

1
2
Find what: .*getElementById\(
Replace with: ""

Tip - Regex:

Before:

1
"UserName").value

After:

1
"UserName"

1
2
Find what: \).*
Replace with: ""

Tip - Regex with parameter

1
2
Find what: (c:.*)
Replace with: ]\n$1 [

Tip - How to “mark” multiple “words”

  • Open Find dialog from the Search menu:
  • Click on the Mark tab
1
2
3
Find What: (Yahoo|Goku|Candy)
Search Mode: Select Regular expression radio button
Click Mark All

Tip - Line up by Comma, equalSign or clipboard character

  • TextFX > TextFX Edit > line up multiple lines by
    Align

Tip - Box Selection

  • Hold down the Alt key while doing a selection
  • Use can also just use keyboard: Shift+Alt+DownArrow
    Align
    Align

Tip - Multi-Editing(Clrl+Mouse click/selection)

  • Enable Multi-Editing from Settings>Preferences>Editing>Multi-Editing Setting>Check the chekbox
  • Press Ctrl and click at desired places to have multiple cursors appear.
  • Continue typing as normal and typed characters will appear at each of the cursor location.

Tip - How To Insert Incrementing Numbers

  • Use box selection to place cursor in front of multiple lines.
  • Edit>Column Editor…>Number to Insert>Fill desired values

Before:

1
2
3
aaa
bbb
ccc

After:

1
2
3
1aaa
2bbb
3ccc

How to find Nth character in Notepad++

  • Press Ctrl+G and choose offset. Enter N.

Todo

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

FirstNameA LastnameB
FirstNameA LastnameB
FirstNameA LastnameB

[0-9](.)

\1

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

FirstNameA LastnameB, 1
FirstNameA LastnameB, 100
FirstNameA LastnameB, 1000

([0-9]) (.)

\2, \1

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

LastnameB, FirstNameA
LastnameB, FirstNameA
LastnameB, FirstNameA
[0-9] ([a-zA-Z]) ([a-zA-Z]*)

\2, \1

1 FirstNameA LastnameB
100 FirstNameA LastnameB
1000 FirstNameA LastnameB

LastnameB, FirstNameA
LastnameB, FirstNameA
LastnameB, FirstNameA

[0-9] ([^ ]) (.*)

\2, \1

(.) - (.)
\1. \1. - \2