Tag Archives: notepad++

Regex Support in Notepad++

I’ve always loved Notepad++ and still think it has a place in this new world of Atom, Brackets, Sublime, Visual Studio Code et al. Notepad++ fills that sweet spot where you need something more powerful than a simple text editor, but something short of the “new coding editors”.

I recently had to massage some data, which I had extracted from an Excel file, into a csv file. It kinda looked like this and went for 800 lines or so:

13,Abdomen
15,Lower leg
22,Upper limb

I needed to change that, so that the text was enclosed in single quotes as so:

13,’Abdomen’
15,’Lower leg’
22,’Upper limb’

I did not really want to manually type those single quotes around the text for a file with 800 lines “and change”. And there was no simple find and replace opportunity unless I turned to regex!

The pattern I used was reasonably straight forward. There were 2 things I had to match:

  1. the integer before the comma (a primary key); and
  2. the text following the comma.

This would allow me to leave the primary key in tact, whilst replacing the text with itself wrapped in single quotes.

In the Find what input, I added the regex: (\d+),(.*)$
And in the Replace with input: $1,'$2'

I’ve included a screenshot below:

npp-regex

And don’t forget to click the Regular Expression radio button at the foot of the dialog. Pretty nice regex support saving a huge amount of time for me.

Change the View Source Editor of Firefox

Firefox is highly configurable. One of the many things that it affords users, in terms of configurability, is the ability to choose the application that they want to use to view the source markup of pages loaded in the browser. Personally, my weapon of choice is notepad++ – an excellent, free text editor which has many cool features and is highly extensible.

So, to make notepadd++ the view source editor of Firefox, follow these simple steps:

  1. open firefox and type about:config in the address bar.
  2. at the top of the page, immediately below the tab, you will see a textbox which enables you to filter the possible settings. Type in “editor”, as depicted in the screenshot below.
  3. change the value of view_source.editor.external to true.
  4. enter the filepath to your installation of notepad++ in the view_source.editor.path configuration item.

Change Editor


You’re done. Next time you fire up “the fox” and click View/Page Source (or ctrl+U), the markup for that page will open in notepad++, with nice syntax colouring and all its other concomitant features.