john c. j.
john c. j.

Reputation: 1175

Multiple selections at the beginning of each logical line

Is there a way for "clever" use of multiple selections with long lines?

Here is what I mean:

For example, you have multiple lines (2 short and one long) and you want to insert dot at the beginning of each of them.

Try it yourself:

foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar barbar bar bar bar bar bar bar bar bar bar bar
baz baz baz baz baz baz baz baz baz baz baz baz baz baz baz baz

Select all (Ctrl-A), then split into lines (Ctrl-Shift-L or Menu > Selection > Split into lines) and then press Home.

You will see, that there is a problem with line 2 - the caret was moved to the beginning of visual line, instead of beginning of logical line.

Actual result:

enter image description here

Desired result:

enter image description here

So, if you try to press "dot" on your keyboard now, you will have an error at line 2 - the dot will be somewhere in the middle of line 2, instead of beginning. Is there way to fix/workaround it?

Edit: I have "word_wrap": "true" in my settings.

Upvotes: 1

Views: 40

Answers (1)

Keith Hall
Keith Hall

Reputation: 16065

You can achieve this with one extra step. Expanding the selection to the line Ctrl+L then pressing Left Arrow (instead of Home) to unselect it and leave the carat at the hard BOL.

So the full sequence would look like this:

  • Select All
  • Split into lines
  • Expand selection to line
  • Left arrow key

Upvotes: 4

Related Questions