397

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

11 Answers 11

503

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)

20
  • 60
    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, 2018 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. Apr 29, 2018 at 23:58
  • 17
    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, 2018 at 2:08
  • 8
    @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, 2018 at 5:45
  • 32
    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, 2018 at 9:13
139

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

Screenshot: enter image description here

10
  • 1
    For me it is Shift+Cmd and mouse. Maybe it has changed? Feb 13, 2018 at 9:01
  • 1
    Please update the answer as it is now Shift+Cmd on OSX. Sep 26, 2018 at 7:56
  • 4
    It has not changed. Yours is Shift+Cmd because you chose "Selection > Switch to Cmd+Click for Multi-Cursor"
    – Eric
    Oct 30, 2018 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, 2019 at 16:17
  • 4
    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. Mar 8, 2019 at 21:28
27

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.

VS Code - Selection Menu - Switch to

5
  • 10
    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, 2020 at 16:08
  • @omostan: Agreed. They do not work at all. Jan 1, 2021 at 0:55
  • 2
    To anyone looking through these answers: this is the one that works!
    – Willem
    Mar 3, 2021 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 Apr 3, 2021 at 14:35
  • This should be the answer. Aug 11, 2022 at 18:46
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, 2019 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. Jul 9, 2019 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, 2019 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. Jul 21, 2019 at 15:49
9

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

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

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

7

As none of the existing answers mention this:

The simplest way to achieve the desired result (as of April 2018 version 1.23) is to middle click and drag.

1
  • 1
    Works for me, tested on both Mac and Windows.
    – ScottCate
    Dec 28, 2021 at 18:20
2

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

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.

0

Click the somewhere at top line of the text. Select none or select some text. Hold the Shift key and click the somewhere in the following lines.

1
  • How is this better than accepted answer?
    – Toto
    Dec 16, 2021 at 12:18
0

Sublime text has this shortcut to select columns: Ctrl + Alt + Up or Ctrl + Alt + Down

So with just adding this extension to VSCode: Sublime Text Keymap and Settings Importer.

You can use the shortcut and done!.

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.