[notepad++] Notepad++ Multi editing

How can I have multiple cursors in Notepad++?

I will have a couple of tab delimited values . I need to write a query for all of these values. For example, if I get an Excel file with values like this:

1234 xyz pqr
2345 sdf kkk
...

I want to copy this whole piece of data into Notepad++ and write the query, inserting all the values at once.

Like this:

Insert into tbl (1234, xyz) where clm = 'pqr'
Insert into tbl (2345, sdf) where clm = 'kkk'
...

I used to do it with my previous text editor Ultraedit. Can this be done using Notepad++?

This question is related to notepad++

The answer is


Yes: simply press and hold the Alt key, click and drag to select the lines whose columns you wish to edit, and begin typing.

You can also go to Settings > Preferences..., and in the Editing tab, turn on multi-editing, to enable selection of multiple separate regions or columns of text to edit at once.

It's much more intuitive, as you can see your edits live as you type.


Notepad++ has a powerful regex engine, capable to search and replace patterns at will.

In your scenario:

  1. Click the menu item Search\Replace...

  2. Fill the 'Find what' field with the search pattern:

    ^(\d{4})\s+(\w{3})\s+(\w{3})$
    
  3. Fill the replace pattern:

    Insert into tbl (\1, \2) where clm = \3
    
  4. Click the Replace All button.

And that's it.

NotePad++ replace window screenshot


Notepad++ only has column editing. This is not completely the same as multiple cursors.

Sublime Text has a marvelous implementation of this, might be worth checking out...
It's a relatively new editor (2011) that is gaining popularity quite fast: http://www.google.com/trends/explore#q=Notepad%2B%2B%2C%20Sublime%20Text&cmpt=q

Edit: Apparently somewhere around Notepad++ version 6.x multi-cursor editing got added, but there are still a few more advanced features for it in Sublime, like "select next occurrence".


You can use the plugin ConyEdit to do this. With ConyEdit running in the background, follow these steps:

  1. use the command line cc.spc /\t/ a to split the text into columns and store them in a two-dim array.
  2. use the command cc.p to print, using the contents of the array.

You can add/edit content on multiple lines by using control button. This is multi edit feature in Notepad++, we need to enable it from settings. Press and hold control, select places where you want to enter text, release control and start typing, this will update the text at all the places selected previously.

enter image description here

Ref: http://notepad-plus-plus.org/features/multi-editing.html


Notepad++ also handles multiple cursors now.

Go into Settings => Preferences => Editing and check "Enable" in "Multi editing settings" Then, just use Ctrl+click to use multiple cursors.

Feature demo on official website here : https://npp-user-manual.org/docs/editing/


In the position where you want to add text, do:

Shift + Alt + down arrow

and select the lines you want. Then type. The text you type is inserted on all of the lines you selected.


You can use Edit > Column Editor... to insert text at the current and following lines. The shortcut is Alt + C.


The easiest method to solve your problem (without going to a different editor or learning regex) is to record a macro.

  • Place your cursor at the start of your text, click the 'record' button in the ribbon, and then edit just that one row of text. You may only use arrow keys or ctrl+arrow keys to move around characters/words rather than clicking with your mouse. The 'home' and 'end' keys are also useful.
  • When you're finished with that one line, move your cursor (again without using the mouse) to the start of the next line.
  • Click the 'stop recording' button.
  • Click the 'play macro' button to check that it works on the next line as expected.
  • Click the 'run macro multiple times' to do it again, and again, and again... :P
One advantage of this over 'multi-editing' cursors is you don't have to manually click and place cursors on every single row. The second advantage is that you can work with tab-delimited data that doesn't have consistent size/length - just use ctrl+left/right to skip words.

Honestly, macros in N++ have saved about a year of my life.