Reputation: 1721
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++?
Upvotes: 172
Views: 271111
Reputation: 11
Original answer : https://superuser.com/a/1617635/1118822
Notepad++ don't has one option/shortcut to easily get multiple carets at the end of several lines. But you can do some of these tricks:
Remember you need to enable always the Multi-Editing on Settings/Preferences/Editing/Enable Multi-Editing checkbox.
You have 2 options:
Option 1 - Without any extra plugin
CTRL+click on each line (it doesn't matter in which part of the line you click) you want to add one caret to the end. When you placed a cursor on each line you want to edit, press END key to move all carets to the end of the line they were placed.
Option 2 - Using BetterMultiselection Plugin (that's the solution !)
Install the BetterMultiSelection Plugin within the Plugins Admin window (on Plugins menu) After the restart of Notepad++ you need to enable the BetterMultiSelection plugin on the plugins menu. Do a column selection with ALT+mouse Press END key. Voila ;-)
Upvotes: 1
Reputation: 1160
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.
Refs: https://cathrinewilhelmsen.net/2015/12/03/notepad-multi-editing , https://npp-user-manual.org/docs/editing/#multi-editing
Upvotes: 90
Reputation: 3055
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/
Upvotes: 42
Reputation: 49
You can use the plugin ConyEdit to do this. With ConyEdit running in the background, follow these steps:
cc.spc /\t/ a
to split the text into columns and store them in a two-dim array. cc.p
to print, using the contents of the array. Upvotes: -1
Reputation: 5213
Notepad++ has a powerful regex engine, capable to search and replace patterns at will.
In your scenario:
Click the menu item Search\Replace...
Fill the 'Find what' field with the search pattern:
^(\d{4})\s+(\w{3})\s+(\w{3})$
Fill the replace pattern:
Insert into tbl (\1, \2) where clm = \3
Click the Replace All
button.
And that's it.
Upvotes: 11
Reputation: 8622
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.
Upvotes: 95
Reputation: 61
The easiest method to solve your problem (without going to a different editor or learning regex) is to record a macro.
Upvotes: 6
Reputation: 724352
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.
Upvotes: 227
Reputation: 1987
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".
Upvotes: 1
Reputation: 32204
You can use Edit > Column Editor...
to insert text at the current and following lines. The shortcut is Alt + C.
Upvotes: 23