microsoft/vscode

Improved column selection (Alt+select)

glen-84 opened this issue Β· 185 comments

The column selection implemented in #1515 is a start, but it's a bit awkward and unintuitive compared to other editors.

With the following editors or IDEs, you can create a column selection starting from where the mouse is clicked/dragged:

  • Atom (with Sublime Style Column Selection)
  • Eclipse
  • Notepad++
  • Programmer's Notepad
  • Sublime
  • Visual Studio 2015

At least Eclipse, Programmer's Notepad, and VS2015 support virtual whitespace as well, creating a complete square/rectangle.

Some of them also don't show multiple cursors, which I think looks better.

Other users were also expecting this behaviour (see here and here).

dvlsg commented

You can knock the assumed off sublime, I can confirm it works that way. The shortcut isn't alt-click for me on windows, but the selection does start where you click.

This is our target behaviour, and hopefully possible when virtual space is supported.

vs

dvlsg commented

Looks good to me, I think.

Is there any hope of support for multi-cursors that aren't necessarily next to each other?

For a contrived example, say I have JSON with integer values, but they really should be doubles. With multi-cursors, I can accomplish that fairly easily. Will this be possible with the proposed block column selection?
multi-cursor-select

Today, the column selection is piggy-backed onto the multi-cursor support (i.e. it is logically represented and consists of multiple cursors). This makes it indeed behave differently than Visual Studio, for example.

That being said, with the exception of empty lines (virtual whitespace) we are not that far:

column-select

@dvlsg We have multi-cursors since v0.1.0. Please see https://code.visualstudio.com/docs/editor/editingevolved#_selection-multicursor

dvlsg commented

Oh awesome! My apologies for missing it in the release notes -- thanks for taking the time to add the link, I appreciate it.

#11830 may provide a more clear description of the expected behavior.

@nholthaus unfortunately I don't think this can be implemented until virtual space is implemented - that should probably be a feature request of its own.

@nholthaus From #11830

Most programs with column mode (visual studio/notepad++/kdevelop/etc) have the following user experience:

  1. hold the keyboard shortcut/toggle column mode.
  2. click somewhere. This is the selection 'start' anchor.
  3. drag somewhere. This is the selection 'end' anchor.

This is not how Visual Studio 2015 behaves for me:

  • I click somewhere
  • I press and hold shift + alt
  • I click and drag somewhere else
  • the anchor is the location before pressing shift + alt
    shift-alt-vs

@alexandrudima yeah but visual studio also has an alt button column mode that does what I described, which is the only one I'd ever use. Visual studio code doesn't seem to have the equivalent, or if it does it doesn't work on linux.

Oh, ok, we only added the shift+alt+ behaviour. IMHO we first need to make the mouse gestures configurable as alt+ clicking is occupied by adding a new cursor (a feature VS does not have) and then we can allow customizations of the modifiers + clicking and add this other way of column selection

Cool. I'm not concerned at all if the shortcuts don't match, as long as the functionality could be accessible somehow.

@alexandrudima Also (on Kubuntu) alt+click moves the window, it doesn't add a cursor. Does that sound like I should file a bug report?

We have had the report multiple times. It boils down to supporting customization of mouse shortcuts (#3130)

@alexandrudima do you intend to implement virtual space in the furture... e.g. hold alt and click somewhere where there aren't any characters yet still have a caret there? Typing then inserts the spaces up the caret automatically.

smuuf commented
  1. Is there any specific reason why multi-cursor placing is mapped to ALT button instead of Sublime-like CTRL? I have a history with Sublime (as opposed to, eg., Visual Studio) and CTRL is more natural to me (I know me is not an argument, but ...). Is this something that could be configurable? I don't see it in keybindings config. 😞 ... If ALT is something only Code does, then I would definitely vote for the quickest possible change to CTRL-behaviour, so there are as few people as possible who would have to re-adapt.
  2. Is there any specific reason why block-selection mode is made with SHIFT+ALT+LEFT-MOUSE-CLICK fingerbreaker instead of just MIDDLE-MOUSE-BUTTON? Just why? Give us the MIDDLE-MOUSE-BUTTON :) Or give us a configurable keybindings for this. (I, sadly, don't see any for this.)

I don't mean to nag :) ... I just wonder these questions every time I work with multiple cursors and block selections in Code. Having these features behaving like in Sublime (from which migrated to Code, mainly because of the debugging tools) would be such a workflow-booster! ❀️

Editors that could be added to the list are jEdit (it uses ctrl instead of the much more standard alt, but otherwise works the same as the other listed editors), Qt Creator, and IAR Embedded Workbench.

I think column selection should definitely use alt+click because it is the standard shortcut, and placing multiple cursors should use something else.

Fania commented

I'm piggy-backing this issue as I think it fits here.
I'd like to add that it would be nice to have column select respect (i.e. ignore) the wrapping of long lines of text.
I encounter this all the time in Latex - writing out a list of sentences and wanting to add the "\item" command in front of all of them but it messes up lines that wrap across the page.
And no, I wouldn't want to disable line-wrapping every time I want to use column select.
Does that make sense?
columnwrap

It would be good if I could alt-drag without shift.

In general, a drag means select and alt drag means select rectangle. alt-drag works in many other places including away from coding editors, e.g. MS Word & the default Mac OS terminal.

Shift-click means create a selection from the current cursor location to the mouse position. Subsequently dragging it can be used to make adjustments.

The two are separate things that can be used together, or one at a time. Shift-alt-click should start the rectangular selection from the current cursor position, which it does. Alt-drag with no shift should start a new selection from the initial click of the drag.

Any updates on this feature request ?

Because a long time notepad++ users like me find hard to neglect this feature !

jnm2 commented

Yes! I've been wanting the same thing for months. I want to be able to Alt + left mouse drag a rectangle without being affected by the cursor position prior to starting the drag, just like in editors like Visual Studio or Notepad++ or even Word and Outlook.

@nholthaus Yes, Ubuntu has this problem with Alt+Drag movement of windows, and it was a big pain for me too. I haven't heard about the same type of interaction anywhere else, so it's likely an issue for Ubuntu.

@smuuf You make a very good point! Shift is supposed to select ranges, Ctrl is supposed to add items to selection. This is the most expected behaviour, and VSCode must have implemented multiple cursors with Ctrl. That'd better be fixed soon, because otherwise POLA would be already broken by non-compliance to legacy behaviour, and VSCode would go in the nice list of Vim and Emacs. But that's, probably, another issue.

Also there's a good reason Ctrl+Shift+C is rarely bound in any of the editors: Shift and Ctrl+C are often pressed in short succession, and there's a good chance to press Ctrl+Shift+C. On VSCode under Windows it opens console window, that is even impossible to close with Alt+F4.

I would also appreciate a proper column select, as well as the current column select (along with other key+click type actions) be configurable via keybindings.json

xgqfrms/xgqfrms#13

πŸ˜žπŸ”«

Being able to do column selection via the middle mouse wheel is literally whats keeping me from making VS Code my main editor.

it is interesting to create a function for sum in column mode, just like in uestudio

Any news on this? Tried latest version of VS Code, and indeed box selection works... BUT there's the major drawback that we have to click before we press the shortcut to set the box selection start location. Super annoying! 😠

As others have mentioned, I would expect:

  1. hold the keyboard shortcut/toggle column mode.
  2. click somewhere. This is the selection 'start' anchor.
  3. drag somewhere. This is the selection 'end' anchor.
jnm2 commented

It has to be Alt+drag, where the start point is wherever the drag started and the end point is wherever the drag ended. It's so common and so irritating on a regular basis that VS Code is weird.

I know I'm late to the party here, but I would love to be able to use the middle mouse button.
click to set start position, drag to select.
I'm not a fan of this three-step process, it feels awkward and I'm having a tough time being productive with it. I keep switching to ST2 frequently whenever I need to do text wrangling.

@dasDaniel You're not late to the party. Issues on github need regular messages in them, otherwise they tend to be closed for "lack of support". This is a hot issue for 2 years, and it's a shame nobody's concerned. It doesn't even have a "bug" tag yet. We still need more people who are late to this party.

I really want to use visual studio code but this is the only thing stopping me. I use alt+select a lot in a number of text editors and IDEs and visual studio code's inconsistent implementation is much to cumbersome to get used to.

Though its not super ideal i found a bodge for this in Sublime text.
https://www.granneman.com/webdev/editors/sublime-text/packages/how-to-install-and-use-sublime-alignment/
this is how i'm using it to add mass comments to python code:
1)middle mouse to select the end of the lines that i want comments on.
2)with the delimiter set to "#" i use the alignment package.
3)if needed i use the middle mouse to select behind the "#"s and add more tabs

masscommentsublime

I too vote for middle button column selection. Coming from SubLime and doing a lot of text manipulation this is definitely essential.

Column selection was mentioned in the roadmap:
https://github.com/Microsoft/vscode/wiki/Roadmap#editor

I also throw my vote in there. Middle mouse button column selection in sublime is very productive. Would love to see it in vscode.

Sublime user here, trying out vscode for the first time. I’m finding a lot to like in vscode, but the wonky column select behavior is a real turn-off.

I migrated TextMate > Atom > Sublime > VSC

VSC is the only editor I've used that is missing this kind of block select using Alt+mousedrag.

Also coming from an editor (Webstorm) where I used to abusively alt+click+drag to perform multiline edit.
It seems totally essential for me now.
I don't think there is a better choice between "ctrl" or "alt" for the key. But at least I think it should not be a combination as "shift+alt".
I would love to see this feature coming really soon !

It is absolutely a must that VS Code implements Alt+Drag for box selection. Any respectable editor has this feature, and this has been requested as far back as 2015.
Shift+Alt+Drag comes close, but it places the anchor at the current caret position instead of the initial click position like it should and is expected to. Plus, it's very cumbersome to require an additional key for such a simple feature.

jnm2 commented

It seems like the team may not realize how many times a day we use this feature in other editors and what impact the half-baked implementation is having.

Even the file editor on the GitHub website supports alt+drag block selection better than VS Code.

Come on Team VSCode!

screen shot 2018-03-13 at 09 59 53

I straight up deleted this program because of this. I really liked everything else, but it felt like trying to write code in word or something.

jnm2 commented

@TarAlacrin To be fair... Word has Alt+drag select. 😜

@TarAlacrin To be fair... Word has Alt+drag select. 😜

Shots fired!

+1. Real pain coming from Sublime Text. :-(

+1, hopefully we get to see this feature soon

I actually just switched to Sublime Text today for this issue.

It seems most of this discussion has been around mouse box selection, but what about keyboard box selection? I assumed VS Code would have functionality similar to VS. i.e. use alt+shift+arrow key. You can customize the VS Code keybindings as described in this SO post to get a clunky version of this functionality, but I expected the functionality to be native and work the same way it does in other apps (e.g. Visual Studio, Notepad++).

Even macOS Terminal does this properly.

edi commented

@gingerbeardman Yep, looks like we're going to get it. Two years since this was requested πŸ˜ƒ

Fingers crossed

I'll believe it when I use it @Eduardjs

screen shot 2018-04-24 at 11 56 27

It's no longer on deck – it's in the backlog.

Looks like the latest release allows middle-click dragging. While this doesn't address the original request to use with Alt, I'm glad to see the middle button multi-column selection working

image

I think two easy changes to make this work more as expected are:

  1. move cursor to click location if column modifiers are held
  2. change column mode modifiers

Surely not much work at all? If I knew where to look i'd create the PR myself. Any hints?

edi commented

@Eduardjs you can achieve this by selecting the lines you need, then typing cmd+β†’ (or cmd+← for beginning of line).

edi commented

This was very disappointing to come across.

Is there no way to implement or override to "standard" functionality of ALT + drag??

Notepad++:

npp-multi-select-3

VSC:

vsc-multi-select-3

I dragged the mouse in pretty much the same area on both - I expected the text to appear in the same area. Also, lines were just skipped entirely. The April update didn't address the issue at all. I'm not bothered about what the shortcut is - alt+LMB or MMB, but am bothered that it works.

This is selecting in again the same general area (starting in the include guards and moving down), but with alt+shift+LMB:

vsc-multi-select-0

I don't even know what that is meant to be!

+1... I love a lot of things about VS code, but I use ALT-drag column select a lot in many other editors and having it not present/not work the same way in VS code is currently a deal breaker :(

pjv commented

sorry if i am missing something, but after two years of people complaining about this issue, how is it possible that the key combination for column selection in vscode has not been made configurable?

all i want, and it seems like all many people in this issue are asking for, is to be able to trigger column selection with alt-drag instead of shift-alt-drag.

that can't be a thing, can it?

It's not just the key combination, what's there isn't really what other editors implement per se. It needs some actual work as discussed earlier in the issue.

pjv commented

It's not just the key combination, what's there isn't really what other editors implement per se. It needs some actual work as discussed earlier in the issue.

not saying it doesn't need other work, but being able to use a familiar key-drag combo to get what there is now would be an improvement and it should be cheap.

not saying it doesn't need other work, but being able to use a familiar key-drag combo to get what there is now would be an improvement and it should be cheap.

The issue is what is in there right now (shift+alt) is kind of related to a "different" feature, so ideally what this issue is asking for is not to convert that feature into the more common Alt+drag box select, but rather to implement the Alt+drag version in addition.

I agree with the general sentiment that I'd love to see any progress on this though :)

pjv commented

The issue is what is in there right now (shift+alt) is kind of related to a "different" feature, so ideally what this issue is asking for is not to convert that feature into the more common Alt+drag box select, but rather to implement the Alt+drag version in addition.

ah so. Got it.

still wouldn't hurt for there to be a settings config for the modifier key for both current and whatever future additional behavior may be added.

+1 million. :) Just make it work like Sublime and others. I think that's what everyone really wants. Make it more standard instead.

Notepad++, Sublime, UltraEdit, even MS Word and Outlook all support ALT+Drag

Maybe I have something amiss in my settings but SHFT+ALT+Drag doesn't work for me (latest May update). I have to use CTRL+SHIFT. Even then, the select doesn't start where I click. It starts where the cursor was. So if the cursor is at the bottom of the screen and I want to select something at the top, I have to click where I want to start, release, then CTRL+SHFT+Drag. It bit nit picky but ... :)

In the words of someone famous and wise, "Give me alt+select, or give me death."

ejabu commented

@nholthaus I used kubuntu 18.04, it's best to change Drag Window from Alt + Drag to Meta + Drag.

Window Behaviour > Window Action > Inner Window

image

+1 on box selection (similar to notepad++), it can be a separate hotkey, whatever, but it's really sad that it isn't in because I am doing my best to like the editor :(

I suppose virtual whitespace needs to exist before this can be achieved?

Holy shit, open thread for more than 2 years with very experienced coders complaining they don't have a critical tool to perform efficiently, and the VS team don't even comment (basically ignore this thread) and go on doing other things. That's what happens when you got so much cash than you don't really care about your users.

Can't believe that's the same thing happening with virtual spaces that would make me switch to VS code in no time. Opened for 2 years... (#13960)

Can someone please smack whoever is responsible for product prioritization here?

edi commented

@jchatel at least it got β€œacknowledgement” lol.

Thats one less step :)

I acknowledged your reply @Eduardjs

lol

o314 commented

@jchatel Embrace, extend, and extinguish

Solutions :

  1. buy linked in
  2. buy github

Ah someone just told me it does not work as intented for Oracle with mysql .
Management from the 90s does not have finish sudying yet...

Is it possible to do this with a plugin or something?

Funny thing is with the latest releases the terminal window will do column select with ALT + Click.

Integrated Terminal

Column selection

Column selection is now supported within the Integrated Terminal via Alt+click.

This does actually already kinda work in VSCode text editing: cmd-shift click drag. I think the most annoying thing is that it's just not the conventional alt-click like in every other editor.

screen shot 2018-08-21 at 08 48 39

@janbaykara it doesn't work the same as in other editors (including, but not limited to, position of cursor and columns extending into virtual white space), which is the point of this issue "improved column selection"

CTRL+SHIFT CLICK DRAG works on Windows as well. What I don't like is say the cursor is at the bottom of the screen and you CTRL+SHIFT and lick on something towards the top. Your selection starts from where the cursor is at the bottom not where you clicked. IMO, the cursor should relocate to where you start your click to start your selection.

I agree, if I'm dragging and having live response, I would like to see the selection start where I clicked, not where the cursor was before I started.

Other than that I'm pretty happy with the feature, and I found I was able to live without it for 2+ years.

Bump! Please fix this issue. This was by far my favorite feature of other text editors and this is a deal breaker for me.

IMO, the cursor should relocate to where you start your click to start your selection.

Amen, @boeningc! If I don't get this feature I will probably just curl up in a ball in the corner and starve to death. I can't handle not having it.

Having said that, I love VSCode, so thank you VSCode team! πŸ‘

This absolutely has to happen. Please fix.

+1, this is such a useful feature to have and something Notepad++ does perfectly.

Also, can we not lock tickets like #28757 ("Vertical Selection via Alt + {Mouse Select}") indiscriminately? The answer given was completely not was asked for, and there's no way to indicate where to find the duplicates (aka this ticket) since replies are locked to collaborators only.

@CheetahChrome if you are out there, you're not alone brother...

This situation is like nails on a chalkboard for me. The indiscriminate close felt like a slap in the face. Thx.

You can get box-select with Ctrl+Shift -> Drag. But what I can't figure out is how to get box-paste. It inserts new lines at the point of paste instead of pasting over existing lines. Does anyone know if this is possible?

It is not possible, because VS Code still ignores the integrity of an essential feature such as column selection.

This is the one of two issues that is preventing me from moving away from a dying product... PowerShell ISE.

Honest question: Is there a way I can see if the VS Code team even plans to address this? How do they decide what to work on? Is there a roadmap? I know the decision is greatly impacted by number of thumbs up, but that's it. Instead of pinging this issue over and over which is not helpful, I'd like a way to see when this will be addressed, to ease my impatience.

@rcdailey
https://github.com/Microsoft/vscode/wiki/Roadmap (out-of-date by a year)

Happy Coding: At its core VS Code is a lightweight, keyboard focused, multi-language code editor. VS Code is already pleasant to code with, and we want to make the experience even more pleasant, for both new and existing users.

Yet they ignore this one feature that makes the editor so unpleasant to code in, as well as internationalisation and character set support issues.

https://github.com/Microsoft/vscode/wiki/Iteration-Plans (current)

"Good luck with that"

s2t2 commented

has anyone found a way to column select by dragging (on Mac OS)?

It doesn't matter to me which keys are involved. Although I'm used to either shift + control + drag or control + drag or alt + drag

EDIT: ahh jk, shift + command + drag is working!

h/t: https://superuser.com/questions/1052795/selecting-columns-in-vs-code#comment2045631_1168023

I have a mouse with a wheel and when I hold it down and drag down and across it selects columns and gives multiple cursors. I can't find a setting for it so it looks like it is built-in? I am fairly new to vscode so might be missing the setting.

One more vote here to replicate the Visual Studio experience for "Alt-" click and "Alt-" drag including block, vertical selection and also placing the cursor and / or the selection out to the right past end of line, cleanly and in a vertical line, not ragged with the existing text. To try this open a text file in Visual Studio and alt-click or alt-drag in the area to the right of the text. The new product should just keep that feature.

Baffled code doesnt have this fundamental thing thats going back to msdos.

Thanks @janbaykara. On my windows machine, this works with ALT + SHIFT + Click .

It still behaves differently from the terminal, as it starts the selection from the current cursor position.

3 YEAR anniversary of this issue on 2019-04-16 πŸ€¦β€β™‚οΈ

@gingerbeardman - Take a look at pull request #66445.
And issue #66444 - Resolve the column selection conversation

Great! Now we just need virtual whitespace and maybe we can finally close this. :)

I think this reply illustrates what virtual whitespace means in practice: #5402 (comment)

ie. selection expands on to areas that have no text

Changing the Multi Cursor Modifier to ctrlCmd breaks the ability to Ctrl+Click on a symbol to view its definition.