263

Does VS 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 VS Code does not behave this way.

354

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.

  • 37
    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
  • 10
    @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
  • 11
    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
  • 2
    @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
  • 11
    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
87

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

  • 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
  • @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 – Peter Nore 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
9

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 VSCode's commandoptionshift + arrow keys that I find more natural to work with.

  • 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
  • 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
5

As of VSCode 1.2 they have full column selection, see https://code.visualstudio.com/docs/editor/codebasics#_column-box-selection

  • "The real answer", etc. – Orangutech Feb 1 '19 at 19:20
  • 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.

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.