Sublime Text 2 multiple line edit
Solution 1
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
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
Worked for me on OS X + Sublime build 3083:
OPTION (ALT) + select lines
Solution 4
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.
- Cmd + F (Find)
- Regexp:
[^ ]+
(or\d+
, or whatever you prefer) - Option + F (Find All)
- Edit it
Hotkeys may vary depending on you OS and personal preferences (mine are for OS X).
Solution 5
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.
Related videos on Youtube
Syperus
Updated on July 08, 2022Comments
-
Syperus almost 2 years
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?
-
Alexander almost 10 yearsIt is probably late to answer this question, but here is a link where you might find an answer for question. sublimetext.com/docs/3/…
-
-
Syperus over 10 yearsYes, but how can I edit every number on the lines at once too? So like if i were to do only the first line I could edit every number on the first line at once? If that makes any sense
-
meatballs over 10 yearsyou can't - you can only have the cursor in one place on any given line. But you can move it to the start of the line, add 0x, use alt > to move along one word and add 0x again.
-
MattDMo over 10 yearsThat's not true - you can have as many cursors as you want on a line. All you need to do is
Ctrl-click
(in Windows) to place them. -
Syperus over 10 years@MattDMo YES!! That's exactly what I was looking for. Do you by chance know the keyboard shortcut to selecting all them like that? I'll look around and see if I can find it.
-
elomage over 9 yearsNo plugin required. Use Alt+Enter at the end for Linux.
-
user1063287 almost 5 yearswhen i used
Ctrl
+Shift
+L
, it selects all the lines, but the cursor on each line is either at the beginning or end of the line. if i then press the left arrow, in an attempt to get all cursors back to the beginning of each line, it moves the cursors backwards relative to where they are, so they are still not uniformly at the same position in the line. how do i get all the cursors at the start of the line? (for context, i am just trying to add[space]*[space]
at the beginning of each line). -
user1063287 almost 5 yearsoh, i think i figured out answer to my last comment, adding here in case it helps anyone else in the same situation - after
Ctrl
+Shift
+L
, whilst selection is still highlighted, doCtrl
+Shift
+Right Arrow
, this creates a cursor that spans all lines and then you can move it to the beginning of the lines and add your desired text to the beginning of all lines. -
apaderno over 4 yearsAlt+F3 works also on Linux, and with Sublime Text 3. This is the quicked and easier way to edit the same string in a file.
-
ovicko over 2 yearsalso consider devs using other OS like Windows/Linux etc