Malantheon
Malantheon

Reputation: 33

VS Code editor: how select everything until next tag - or next occurent of <

There are keyboard shortcuts to select everything between matching brackets and to grow and shrink your selecting, however sometimes there is another markup inside. Is there a way to select everything from coursor to beginning of the next element? For example the cursor sits after the

tag. When pressing shortcut I want to:

<p>Select only this text<span>and not this</span>, also not this.</p>

Thank you

Upvotes: 2

Views: 1161

Answers (1)

rioV8
rioV8

Reputation: 28663

You can use the extension Select By.

In your settings.json

  "selectby.regexes": {
    "till-angle-bracket": {
      "forward": "<",
      "forwardInclude": false
    }
  }

You can use the command Select text range based on regex and select till-angle-bracket from the list

or you can add a keybinding

  {
    "key": "ctrl+shift+y", // or any other key-combo
    "when": "editorTextFocus",
    "command": "selectby.regex",
    "args": ["till-angle-bracket"]
  }

Upvotes: 2

Related Questions