336

Does Visual Studio Code support selecting columns of text?

I have not yet found this feature, so I am wondering if it is hidden somewhere. I am familiar with holding down Alt while selecting text, but Visual Studio Code does not behave this way.

6
440

In Visual Studio Code version 1.0, you can now select columns by holding down Shift+Alt, then click and drag with the mouse. This can also be done using just the keyboard by holding down Ctrl+Shift+Alt and then using the arrow keys.

On latest version of vscode - 1.45.1, you can achieve same by Shift+Alt itself ( verified in May 2020)

15
  • 50
    It's really "click, shift+alt+drag". Much less convenient than VS classic's "alt+drag". Is there any way to make VS Code work exactly like VS? – Steve Feb 1 '18 at 19:59
  • 13
    @Steve File > Preferences > Keyboard Shortcuts. Then search for cursorColumnSelect, then you can modify the keyboard shortcuts. This is done on VS Code, version 1.22. Of note, columnSelect is what you would need to change for Shift + Alt + Drag, but right now, there's no way to register a mouse button down event in Electron. – tom_mai78101 Apr 29 '18 at 23:58
  • 14
    This not a column select by the definition of any editor that's ever had column select. VSCode doesn't put columns through virtual space making it useless since it's not actually a column. Compare actual column select to VSCode's strange not really column select – gman Aug 15 '18 at 2:08
  • 3
    @FranklinYu, visual studio (not vscode), emacs, intelli-j, notepad++, slickedit, and lots more... Been using real column editing since at least brief in the late 80s. Not saying that's the first, just that's when I started using and needed the feature and find that editors that are missing it hinder me. – gman Sep 18 '18 at 5:45
  • 25
    the fact that I have to google it and come here everytime I need to do this, means this shortcut is just not good enough.. – Alex R Oct 17 '18 at 9:13
109

On macOS: Shift+Option and mouse, or Shift+Option+Cmd and arrow keys

8
  • 1
    For me it is Shift+Cmd and mouse. Maybe it has changed? – Lars Nyström Feb 13 '18 at 9:01
  • 1
    Please update the answer as it is now Shift+Cmd on OSX. – Kevin Farrugia Sep 26 '18 at 7:56
  • 3
    It has not changed. Yours is Shift+Cmd because you chose "Selection > Switch to Cmd+Click for Multi-Cursor" – Eric Oct 30 '18 at 22:13
  • 2
    @Eric I basically have defaults, haven't selected that option, and it's Shift+Cmd for me in vscode insiders 1.31 on mac 10.14 – Myer Mar 8 '19 at 16:17
  • 1
    The default is Shift+Option. If you select "Selection > Switch to Cmd+Click for Multi-Cursor", then it will change to Shift+Cmd. If you then select "Selection > Switch to Alt+Click for Multi-Cursor", then it will change back. – DrStrangepork Mar 8 '19 at 21:28
10

For the ones who have tried to use the Alt Key + Mouse Selection, and failed. Try to Click the menu selection as follows:

Menu bar > Selection > {Click} Switch to Ctrl+Click for Multi Cursor. This will change the multi selection the with Ctrl key and mouse as well as enable to selection column selection with the Alt Key + Mouse Selection.

https://i.stack.imgur.com/x8tJN.png

4
  • 7
    I find this answer to be the best and should be the accepted answer. I have no idea why others are given long and inadiquate answers that seem to be accepted by majority of viewers. – omostan Jul 5 '20 at 16:08
  • @omostan: Agreed. They do not work at all. – Peter Mortensen Jan 1 at 0:55
  • 1
    To anyone looking through these answers: this is the one that works! – Willem Mar 3 at 10:35
  • Agreed. This one seems to get to the point. Maybe it was introduced in a later version, but this allows you to use "ALT+CLICK" in VS Code – Matt Kenefick Apr 3 at 14:35
10

I just published an extension for Visual Studio Code that converts a multi-line selection into a column selection. It mimics TextMate's Toggle Column Selection command and serves as an alternate approach to Visual Studio Code's commandoptionshift + arrow keys that I find more natural to work with.

4
  • Your AutoHotKey example is missing this line at the top SetTitleMatchMode, 2 so it accepts wildcard titles. A VSCode window shows Filename.txt - MyFolder - Visual Studio Code – Jack Jul 8 '19 at 6:40
  • @Jack I'm actually not familiar with how AutoHotKey works (those instructions came via a PR from someone else). But it sounds like you're saying that hotkey currently triggers in all apps, not just VSCode? I wouldn't want to make the window title matching too strict, though, since I know that the info in the window title is user configurable. – Erik P. Hansen Jul 9 '19 at 14:26
  • 1
    No currently it doesn't trigger at all because it never finds the exact text Visual Studio Code. Need to set the title match mode to 2 so it searches that the title contains the text. – Jack Jul 9 '19 at 16:08
  • @Jack Thanks for the tip! I've updated the readme. Hopefully the instructions work now but I can't test it as I don't have access to a Windows machine these days. – Erik P. Hansen Jul 21 '19 at 15:49
8

As of Visual Studio Code 1.2, they have full column selection. See Column (box) selection

2
  • "The real answer", etc. – Orangutech Feb 1 '19 at 19:20
  • 1
    On VSCode 1.4 not working as in the documentation - more like the comments above – emem Nov 11 '19 at 16:56
2

On a Mac, to use only the keyboard, I just had to use Cmd+Shift+Opt and then arrow keys.

1

For all you visual learners, there is (as of version at least version 1.55) a graphical menu way to turn it on and a even faster way to turn it off. Go to Selection \ Column Selection Mode to toggle this feature on or off. If Column Selection Mode is enabled, there is a notice in the bottom VSCode status bar (circled in red in my illustration). A quick click on this notice will turn it off.

enter image description here

0

I have tested this on Windows 10 Pro 1909 and Linux Mint 19.3 VSCode 1.45.1 on both OS's. When I was holding Shift+Alt+Mouse Click it was dragging the Window around. What might be a better explanation is this:

HOLD down LEFT mouse button anywhere in the code then press and HOLD SHIFT+ALT. With all 3 Held down drag mouse in any direction with the mouse for column select.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.