Menu Close

Notepad++ Magic

Notepad++ is a free source code editor and Notepad replacement that supports several languages. It is incredibly light-weight (It’s portable version is only 18 Mb) and fast. It runs in the MS Windows environment and its use is governed by GNU General Public License.

Though it is basically a source code editor, the layman can use it for innumerable purposes. It’s versatility is almost magical.

Here are some tasks you could do with Notepad++:

Remove empty lines: If you are having a large text file with 500 or so lines, and you wish to remove the empty lines which are haphazardly spread across the text. Notepad++ can save you hours of fiddling with keys. Just do this.

Select the whole text.
Go to Edit > Line Operations > Remove Empty Lines

And that’s it. The empty lines will disappear in the blink of an eye.

Arrange lines in alphabetical order: You know that you can sort data in the cells of an Excel worksheet in alphabetical order very easily. But did you know that you could effortlessly arrange all the lines in a huge text file in alphabetical order, too? Just do this.

Select the whole text (or just the part you want to re-arrange)
Go to Edit > Line Operations > Sort Line Lexicographically Ascending (or Sort Line Lexicographically Descending, as the case may be)

And that’s it. The selected text will be arranged according to the first letter of each line.

Trim trailing/leading space: When your aim is to do away with trailing or leading space in every line, do this.

Select the whole text (or just the part you want to re-arrange)
Go to Edit > Blank Operations > Trim Trailing Space (or Trim Leading Space, as the case may be)

And that’s it. All the bits of space that is bothering you will be no more.

Select and delete all leading space in multiple lines: This is something you cannot imagine of doing in regular Notepad. If all your bits of leading spaces (or spaces in between lines) are making a straight vertical line, you can actually select them by dragging your mouse down vertically. Here’s what you have to do.

Press down Alt key and keep it pressed
Place your mouse pointer at the top left of the column of space and drag it down to the bottom right corner so that the whole column of space is selected (Alternatively, the same can be done by using Alt + Shift + Arrow keys)
Hit Delete

And that’s it. All space will disappear and the whole chunk of text will be magically shifted to the left.

Append text to the beginning or end of each line: This sounds easy if there are only a handful of lines. But what if you have to deal with hundreds of lines of text.
Here’s what you have to do to append text to the beginning of each line.

Go to Search > Replace...
Make sure to select Regular expression under the Search Mode group.
Add ^ in the Find textbox and the text you want at the start of each line in the Replace textbox
Hit Replace all

And that’s it. The text you want appended will be added to the beginning of every line.

Here’s what you have to do to append text to the end of each line.

Go to Search > Replace...
Make sure to select Regular expression under the Search Mode group.
Add $ in the Find textbox and the text you want at the start of each line in the Replace textbox
Hit Replace all

And that’s it. The text you want appended will be added to the end of every line.

Find and replace text in multiple files: Finding and replacing text in the same file is easy. But what if you have to edit the same text in a hundred files in the same directory? With Notepad++, this is easier done than said.
This is what you have to do.

Go to Search > Find in Files
Select Find in Files tab
Enter the text you want to replace in Find what
Enter the new text in Replace with
In Directory select the directory in which your text files are stored
Hit Replace in Files

And that’s it. The text will be replaced in all the files in the folder.

Add line break at a specific character: What will you do when you have to add line breaks at several occurances of a specific character?
Suppose you have to add line breaks after ]- -, this is what you have to do.

Go to Search > Replace...
Under the Search Mode group, select Regular expression.
Enter ]--\s* in Find what
Enter ]--\n in Replace with
Hit Replace All

And that’s it. The line breaks will appear at the desired places.

Replace all text between two characters: Do the following when you have to replace varied text between two characters (suppose the characters are [ and ]).

Go to Search > Replace...
Under the Search Mode group, select Regular expression.
Enter (\[).+?(\]) in Find what
Enter $1$2 in Replace with
Hit Replace All

And that’s it. The text occuring between the two characters everywhere will be replaced.

Add line breaks after a specific character: When you have to add line breaks after a specific character (an equal to sign, for instance), do this.

Go to Search > Replace...
Under the Search Mode group, select Extended.
Enter the character after which you want to add line breaks = in Find what
Enter =\r\n in Replace with
Hit Replace All

And that’s it. Line breaks will be added in the file wherever there is an “=” sign.

Add line breaks after lines containing a specific text: When you have to add line breaks after the lines containing a specific text (STRING, for instance), do this.

Go to Search > Replace...
Under the Search Mode group, select Regular expression.
Enter this in Find what (You can replace STRING with the specific text of your choice): (?-s)(?<=STRING)(.*\R)
Enter \1\r\n in Replace with
Hit Replace All

And that’s it. Line breaks will be added after every line containing the text “STRING”.

Views: Today 1 | Total 145
56 Shares

Leave a Reply

Your email address will not be published. Required fields are marked *

Copy link
Powered by Social Snap