Visual Studio Code: copying text when none is selected.
Posted by jpluimers on 2025/02/19
Last week, I wrote that I switched to Visual Studio Code for most of my text based coding: Visual Studio Code: blazingly fast text expansion with Emmet.
I also use vscode for documentation and text writing, which – yes sometimes I am a copy/paste person too – means you want a bit more flexibility than just copying the selected text.
In most of my previous development tools, either the tool itself, or a plugin, would allow me to copy the word under the cursor if none was selected.
I wanted to change that behaviour too and become more flexible.
So I did some searches:
- [Wayback/Archive.is] vscode expand selection – Google Search a got me the built-in shortcuts I did not know yet:
- [Wayback/Archive.is] Basic Editing in Visual Studio Code
Shrink/expand selection#
Quickly shrink or expand the current selection. Trigger it withShift+Alt+LeftandShift+Alt+Right.Here’s an example of expanding the selection withShift+Alt+Right:
Column (box) selection#
Place the cursor in one corner and then holdShift+Altwhile dragging to the opposite corner:
Note: This changes to Shift+Ctrl/Cmd when using Ctrl/Cmd as multi-cursor modifier.There are also default key bindings for column selection on macOS and Windows, but not on Linux.Key Command Command ID Ctrl+Shift+Alt+DownColumn Select Down cursorColumnSelectDownCtrl+Shift+Alt+UpColumn Select Up cursorColumnSelectUpCtrl+Shift+Alt+LeftColumn Select Left cursorColumnSelectLeftCtrl+Shift+Alt+RightColumn Select Right cursorColumnSelectRightCtrl+Shift+Alt+PageDownColumn Select Page Down cursorColumnSelectPageDownCtrl+Shift+Alt+PageUpColumn Select Page Up cursorColumnSelectPageUpYou can edit yourkeybindings.jsonto bind them to something more familiar if you wish.
- [Wayback/Archive.is] Basic Editing in Visual Studio Code
- [Wayback/Archive.is] vscode expand selection to scope – Google Search got me
- [Wayback/Archive.is] Selecting block of code in Visual Studio Code – Stack Overflow
Use Alt + Shift + → to expand the selection between braces or tags.Use Alt + Shift + ← to shrink the selection between braces or tags.…Use alt + shift + → to expand selection between braces or tags. Then, while keep holding alt + shift. click → again several times to append test from the left side of the braces until the function name as part of the same selection.
- [Wayback/Archive.is] Selecting block of code in Visual Studio Code – Stack Overflow
- [Wayback/Archive.is] vscode expand selection to quotes – Google Search got me
- [Wayback/Archive.is] VSCode tips – How to select everything between brackets or quotes
The build in keyboard shortcuts are great but if you want even more control over your selection checkout the [Wayback/Archive.is] Quick and Simple Text Selection extension by David Bankier.
This extension lets you to:Ctrl + K 'select everything between single quotesCtrl + K "select everything between double quotesCtrl + K `select everything between back ticksCtrl + K (select everything inside parenthesisCtrl + K )select everything inside parenthesis and include themCtrl + K [ or ]select everything between square brackets and include themCtrl + K { or }select everything between curly braces and include themCtrl + K < or >select everything between angle brackets and include them
- [Wayback/Archive.is] VSCode tips – How to select everything between brackets or quotes
- Finally, [Wayback/Archive.is] vscode extension copy under cursor – Google Search got me a reference to an extension that implements my trusted behaviour, but I didn’t install the extension as I wanted to get accustomed to selection expansion first:
--jeroen






Leave a comment