Sublime Forum

Line and multi-line selection

#1

Hello everyone.

I am a trial user for Sublime Text and I was wondering if there was a way to select a whole line of code using (I guess your default is Ctrl+L) and then hitting the up arrow or down arrow to keep selecting lines either above or below?

I am a MultiEdit user and thatā€™s the one key thing that separates ME from the rest, in my eyes. Anywhere on a line of code, I can press shift+up or shift+down and it selects the current line and if I keep pressing the up or down arrows while pressing shift, I keep selecting lines either up or down. Itā€™s a wonderful thing and makes editing a breeze as in most languages lines are pretty much atomic statements.

If there is no way to do that out of the box, then I will see if I can learn some python to make this plugin happen. Just thought Iā€™d ask before reinventing the wheel. :smile:

0 Likes

CodeIntel ported from Open Komodo Editor
ā˜€ I gift a ST2 license to the one that makes me laugh harder
#2

Ok, found the solution already exploring the options, and no python needed! :smiley:

Just for the record:

	<binding key="ctrl+shift+down" command="expandSelectionTo line"/>
	<binding key="shift+up" command="move lines -1 extend"/>
	<binding key="shift+down" command="move lines 1 extend"/>

Does what I want, a bit differently but gets the job done.

0 Likes

#3

This is a great idea, shift+up/down is a fairly crummy key binding. Iā€™ve added support for what you describe in the latest beta, via the command ā€œmove wholelinesā€ - itā€™s bound to shift+up/down by default.

0 Likes

#4

Awesome. Will try it out! Thank you.

0 Likes

#5

Any way to remove this or make it an option? Itā€™s now impossible (i think) to select a long sentence from a paragraph using the keyboardā€¦

0 Likes

#6

Steve, you can change it back by adding key bindings for:

<binding key="shift+up" command="move lines -1 extend"/>
<binding key="shift+down" command="move lines 1 extend"/>

Just to confirm, this is causing you issues for multi-line sentences, as your workflow is to, say, start at the beginning of the sentence, then shift+down to go down to the next line, then press ctrl+shift+right a few times to get to the end of the sentence?

If changing the behavior of shift+up/down is going to trip people up, It may make more sense to have the new behavior only kick in if the selection already contains a newlineā€¦ hrm.

0 Likes

#7

Hi, Jon. Yeah, Itā€™s a problem when Iā€™m writing prose, with wrapping on. With a paragraph of prose in one logical line (ie one terminating CR) but spread over several visual wrapped lines, selecting a sentence spread over several visible lines is now a problem.

The other thing is that I use selection as a preview for deletion, not just copy and cut. I select out what I want gone, get the selection right, and hit delete. If hitting down extends the selection, it threatens to delete code I didnā€™t want deleted. Possibly especially bad when used with shift+pgdn, to select large chunks of code ā€“ say, selecting a binary blob inside an RTF file.

I am generally in the camp of users who want very little extra help from their editor. I use ST as my ā€˜do exactly what I sayā€™ editor. , where I can do -exactly- what I mean to my code. So Iā€™d very much prefer it if ST didnā€™t shift my selection start as I move the end, or insert brackets and quotes, or correct my indentation. Iā€™m laying this out explicitly because I think there may be different camps of users, some who want automatic reformatting and helpful selections and such, and some who really wonā€™t like it. Me, Iā€™m in the minimalist camp.

0 Likes

#8

I have no problem if what I proposed is not the default as I know that not many people are used to that feature, but I find it invaluable. If you make it possible for me to make it happen somehow with rebindings it would be good enough for me. Cheers!

0 Likes