Sublime Text 2 multiple line edit

Sublimetext2SublimetextSublimetext3

Sublimetext2 Problem Overview


I want to edit multiple lines and every "word" within that line. For example:

45 28 42 65
24 87 47 95
01 25 87 98

I want to select every whole number in all lines and put a "0x" before it so it would look like:

0x45 0x28 0x42 0x65
0x24 0x87 0x47 0x95
0x01 0x25 0x87 0x98

I know the Ctrl+shift+L to get cursors on each line, but how can I get the cursors in front of every number to mass edit all at once?

Sublimetext2 Solutions


Solution 1 - Sublimetext2

Highlight the lines and use:

  • Windows: Ctrl+Shift+L
  • Mac: Cmd ⌘+Shift+L

You can then move the cursor to your heart's content and edit all lines at once.

It's also called "Split into Lines" in the "Selection" menu.

Solution 2 - Sublimetext2

Use multiple cursors and column selection.

In your case you just need to place the cursors at the beginning of each column containing the "words".

Linux and Windows

  • Click & drag to select column(s): Shift + RightMouseBtn
  • Add other column(s) to selection by click & drag: Ctrl + Shift + RightMouseBtn
  • Subtract column(s) from the selection: Alt + Shift + RightMouseBtn
  • Add individual cursors: Ctrl + LeftMouseBtn
  • Remove individual cursors: Alt + LeftMouseBtn

Mac

  • Click & drag to select column(s): Option⌥ + LeftMouseBtn
  • Add other column(s) to selection by click & drag: Option⌥ + LeftMouseBtn
  • Subtract column(s) from the selection: Cmd⌘ + Option⌥ + shift + LeftMouseBtn
  • Add individual cursors: Cmd⌘ + LeftMouseBtn
  • Remove individual cursors: Cmd⌘ + Option⌥ + shift + LeftMouseBtn

Then edit as needed. In your case, type 0, x.

You could also navigate as needed to the end or beginning of the words, select the words and surround with quotes or parenthesis, and so on.


References:

Solution 3 - Sublimetext2

Worked for me on OS X + Sublime build 3083:

OPTION (ALT) + select lines

Solution 4 - Sublimetext2

I'm not sure it's possible "out of the box". And, unfortunately, I don't know an appropriate plugin either. To solve the problem you suggested you could use regular expressions.

  1. Cmd + F (Find)
  2. Regexp: [^ ]+ (or \d+, or whatever you prefer)
  3. Option + F (Find All)
  4. Edit it

Hotkeys may vary depending on you OS and personal preferences (mine are for OS X).

Solution 5 - Sublimetext2

I was facing the same problem on Linux, what I did was to select all the content (ctrl-A) and then press ctrl+shift+L, It gives you a cursor on each line and then you can add similar content to each column.

Also you can perform other operations like cut, copy and paste column wise.

PS :- If you want to select a rectangular set of data from text, you can also press shift and hold Right Mouse button and then select data in a rectangular fashion. Then press CTRL+SHIFT+L to get the cursor on each line.

Solution 6 - Sublimetext2

Windows: I prefer Alt+F3 to search a string and change all instances of search string at once.

http://www.sublimetext.com/docs/selection

Solution 7 - Sublimetext2

On Windows, I prefer Ctrl + Alt + Down.

It selects the lines one by one and automatically starts the multi-line editor mode. It is a bit faster this way. If you have a lot of lines to edit then selecting the text and Ctrl + Shift + L is a better choice.

Solution 8 - Sublimetext2

ctrl + shift + right-click it works better that way

Solution 9 - Sublimetext2

If you are looking to select the same word / value in multiple lines to then edit it, you can simply press "COMMAND + D" on the first entry and then keep pressing "D" to select the lines below

Solution 10 - Sublimetext2

It's fine to manually select each number for a small set of numbers like in your example, but for larger collections you can do a regex search which will do the work for you.

Ctrl + F will open the search bar.

Regex searches are enabled by clicking the ".*" button on the far left.

Type in "\d+" to search for all occurrences of 1 or more digits. Clicking the "Find All" button will select each of these numbers separately.

Then you can use Ctrl + Shift + L to convert the selection into multiple cursors. From here you can do as you like.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSyperusView Question on Stackoverflow
Solution 1 - Sublimetext2OwenView Answer on Stackoverflow
Solution 2 - Sublimetext2elomageView Answer on Stackoverflow
Solution 3 - Sublimetext2Jose AlbanView Answer on Stackoverflow
Solution 4 - Sublimetext2FreeNicknameView Answer on Stackoverflow
Solution 5 - Sublimetext2StuckWithSpringView Answer on Stackoverflow
Solution 6 - Sublimetext2tomcatView Answer on Stackoverflow
Solution 7 - Sublimetext2Semih SezerView Answer on Stackoverflow
Solution 8 - Sublimetext2chris_cxView Answer on Stackoverflow
Solution 9 - Sublimetext2DamianView Answer on Stackoverflow
Solution 10 - Sublimetext2Nolan LuckettView Answer on Stackoverflow