Home > front end >  Is there a way to select all text string content in a whole document at once in Visual Studio?
Is there a way to select all text string content in a whole document at once in Visual Studio?

Time:11-29

I'm looking for a quick way to, for example, if this was my HTML document:

<!DOCTYPE html>
<html lang="en">
  <h1>Title</h1>
  <p>Hello</p>
  <p>This is a text line</p>
</html>

Select only Title, Hello and This is a text line all at once, ignoring the tags and non-string code.

Is there a keyboard shortcut or a plugin to do it? I'm working with MacOS on a Mac keyboard.

CodePudding user response:

I am not aware of any shortcut or plugin to do this but you could use a regular expression to replace all of the html tags with nothing:

Find '<[^>]*>'
Replace: ''

eg: https://regex101.com/r/zYb01t/1

Alternatively, if none of the content is hidden you could view the rendered html in a browser, select all ⌘A and copy all the text ⌘C.

CodePudding user response:

You could use this regex:

(<\w >)(.*)(<\/\w >) as show for your code here. The parentheses group the output. What you want is group number two ( (.*) ). According to this post you can achieve this is VScode by using $2.

  • Related