Today share a vscode practical tip, this small tip is very good to use, is when I knocked on the code accidentally found a very practical tip, I believe we may encounter a small problem when copying and pasting others code.

So vscode is a shortcut CTRL +h.

Most people probably know this shortcut, but there are some clever uses for this feature, for example.

When I was developing, I copied a piece of code from the document as follows:

There are many such words in this code, I need to remove the double quotation marks on both sides of the word, otherwise the code will report an error, and it is a waste of time to modify one by one, so I wonder if I can use the substitution method to achieve a large number of code uniform modification. Here’s how I did it:

2. CTRL + H to bring up the vscode replacement window

3. Select to find in the selected area:

4. Click to select regular expression match

5. Write the regular expression you want to match: ‘(\w+)’ at the top, and write the content you want to replace. Because you only replace the double quotation marks around the word, the word is not replaced, so you need to replace the content of the regular expression with the matched content. The replace column says $1, which means externally calling the contents of the first grouping of the re match, and then clicking the Replace All button.

The double quotation marks around the words in the selected area are removed completely:

Summary: This method is suitable for repeated modification of a large number of code, want to use this method flexibly need to master some knowledge of regular expressions, think useful friends can go down to try it yourself. After all, there are certain situations where this method is useful, so I’ll share some of the tips I’ve learned in the code. Click a “like” and collect it