yodalr
yodalr

Reputation: 10902

Is there a 'select between tags' shortcut in Visual Studio Code?

In Notepad++ I used this extension that when I was inside the arrows of any tag in html, I could use a keyboard shortcut to select either only the contents of the tag, or also include the tag into the selection.

Ie.

<div>
  div content
</div>

When I'm in tag I would like to select div content without using mouse to do the selection.

I've seen some suggestions of using the shift+alt+right arrow shortcut, but it really isn't the same thing.

Upvotes: 55

Views: 35986

Answers (3)

user8247953
user8247953

Reputation: 155

Via the "Expand Selection" command:

Move the cursor to the element, then, press Shift+Alt+Right Arrow(→).

First, it will highlight the element, then its line and next the whole tag.

Upvotes: 14

jodyfanning
jodyfanning

Reputation: 1549

The built-in command Emmet: Balance (outward) does what you want. It selects content of a tag and then progressively includes the tag and works outward just like Expand Selection to Tag in Sublime, and sounds like the extension for Notepad++.

You can create a custom keybinding for it as well in the preferences, for example

[
    {
        "key": "ctrl+shift+a",
        "command": "editor.emmet.action.balanceOut"
    }
]

Upvotes: 117

Mark
Mark

Reputation: 181050

Check out the extension expand region. It does what you want quite nicely. Works for html and javascript.

Upvotes: 3

Related Questions