Sublime Forum

How can I unselect first occurrence of multi line selection

#1

I have a simple list of 4 lines. I need to select line 2 and 3.

abc
abc
abc
abc

I put my cursor on second line and do the following:

[super+d] - selects line 2
[super+d] - selects line 3
[super+d], [super+k, super+d] - skips line 4

At this point search wrapped to the first line and made it selected. How can I unselect it ??? [super+k, super+d] messes selection up.

0 Likes

#2

Not sure if it is possible just with keyboard, but you could just alt+click&drag on the text.
Something like this: (http://img.iamntz.com/jing/video_2013-07-30-06@06h55_47.mp4)

0 Likes

#3

You could write a plugin to do it, but does “super+u” do what you want?

0 Likes

#4

No, “super+u” will undo “super+k”, “super+d” which will leave line 4 selected, which I do not want.

0 Likes

#5

[quote=“iamntz”]Not sure if it is possible just with keyboard, but you could just alt+click&drag on the text.
Something like this: (http://img.iamntz.com/jing/video_2013-07-30-06@06h55_47.mp4)

When I click with alt it unselects previously selected lines.[/quote]

0 Likes

#6

Press “super+u” again.

0 Likes

#7

Sure, but this was just a model of real work scenario, where u have a huge source file and those selections are not located one after another. The question is: is it possible to unselect the very first selection, which happens AUTOMATICALLY when Sublime Text wraps super+d command.

0 Likes

#8

Also, why super+k, super+d is not working on this first line ???

0 Likes

#9

Pressing super+u twice will remove the wrapped selection every time, even in real work scenarios.
The problem is that the cmd+k, cmd+d command is slightly broken. I seem to remember seeing a fixed version floating around on the forums, and I tried to find it, but I must be searching for the wrong terms or something.

0 Likes

#10

It will only work in real life if you started your multiselect from beginning of your file. If not, how can you continue after wrap without selecting the first one ?
It would be REAL great if you will find a FIXED version of super+k, super+d !!!

0 Likes

#11

Since “super+u” doesn’t work, you can write a plugin for it.

[code]import sublime
import sublime_plugin

class RemoveFirstCursorCommand(sublime_plugin.TextCommand):
def run(self, edit):
cursors = list(self.view.sel())
if len(cursors) > 1:
self.view.sel().clear()
self.view.sel().add_all(cursors[1:])
[/code]

Didn’t really test it, but it should work. It’s pretty straight forward. I recall add_all not working in ST2, but that could be wrong. If it doesn’t work, simply loop over the cursors and call self.view.sel().add(cursor)

0 Likes