How can visual studio code edit multiple places at the same time? Three methods of vscode editing multiple places at the same time

Time:2019-10-17

Visual studio code code wants to edit multiple places at the same time, how to implement it? Today we will introduce three methods. Please see the details below.

Software name:
Visual studio code 1.18.0 32-bit official Chinese free green
Software size:
53.1MB
Updated:
2017-11-10

I. rename variables

1. First, see if you want to rename a variable when you need to modify multiple codes at the same time. If so, there are ready-madeShortcut key F2。 Select a variable, press F2, and a small window will pop up. Press enter after entering the content, and all the variables will be renamed.

2. But pay attention.In JS file, if this variable is not declared with VaR or const or let, it cannot be renamed.

II. Multi cursor

1, hold downalt,Click with the left mouse button to display multiple cursors.The entered code can be added at the cursor at the same time.

2, hold downCtrl + Alt, and then press the up or down key on the keyboard to make multiple cursors appear on a column.

3. Select a paragraph of text and pressshift+alt+i, the cursor can appear at the end of each line

4. Place the cursor in a place and pressCTRL + Shift + L or Ctrl + F2, the cursor can appear at different places of the word in the page.Sometimes this shortcut key is similar to F2 rename variable., but it is more extensive because it can also be modified against something that is not the same variable or function class as a string.

5, pressshift+alt, and then drag with the mouse, the vertical column cursor can also appear, and multiple columns can be selected at the same time.

6. For any cursor operation, pressCtrl + Ucancel

III. replacement string

1, pressctrl+f, you can search the current page, and then press the small triangle on the left side of the search box.Can switch to replace mode。 Sometimes string replacement is more convenient than multiple cursors, but be careful not to replace what you don’t want to replace.

These are three ways for vscode to edit multiple places at the same time. I hope you like them. Please continue to pay attention to developpaer.

Relevant recommendations:

How to solve VS2010 console program in a flash?

Vs2017 installation error prompt signature verification failure what to do?

How does visual studio code use global search shortcuts?