Select all text between quotes in VS Code?

Viewed 10590

I had to reinstall VS Code recently, I rember using Ctrl+W to kind of smart select everything between quotes but now what that command does is move me to another file/tab instead? Is there a way to do this in VS Code, Ctrl+W was just so easy to me, really helped with deleting or copying strings of text.

5 Answers

As @Mark says in the comment, you can use the "Expand Selection" shortcut, this will first select everything between the quotes.

The shortcut on Windows by default:
Shift + Alt +

And OS X:
Ctrl + Shift + +

Try using the Quick and Simple Text Selection extension.

On a Mac, the extension's default shortcut is k, "

  1. Press and k
  2. let go of of and k
  3. press "

This will select everything in double quotes.

If you want to select everything in single quotes use k, "

It also works for brackets

  • k, [
  • k, {
  • k, (

On Windows, replace with Ctrl

https://github.com/dbankier/vscode-quick-select

Shift + Alt + (Right Arrow) for the word next to cursor Shift + Alt + (Right Arrow)x2 for entire sentence between quotes

After re-reading your question, I noticed that you want to press Ctrl + W to press multiple times to expand your selection

To see and set the shortcut, you can

  1. Press Ctrl/Cmd + Shift + P
  2. Go to Keyboard Shortcuts by typing Preferences: Open Keyboard Shortcuts
    • enter image description here
  3. Search for the command: editor.action.smartSelect.expand
  4. Double click the keybinding to set a new keybinding
    • enter image description here

Summary of answers

  • Most use cases: use @colinD's answer (Alt + Shift ← or →) which expands the selection word by word
  • Press Ctrl + Shift + multiple times to expand the selection's scope
    • it might be different on Windows
  • If you want to select all of the text in quotes and there's a lot of spaces and your cursor is in the middle of the quotes

The best / simplest way to do it I've found on Mac is to click the text anywhere in the quote marks, then hold down Control + Shift and tap the right arrow twice.

Related