VsCode multiple cursor on same variable

1.1k Views Asked by At

VsCode has a command (ctrl+alt+l as shown here) to select all occurrences of the word in a file. It's also possible for the rename symbol. But is there a way to select only occurrences of the same variable ?

In this example would like to be able to select in the same time the word value of the first and third line but not the one of the second line.

def square(value):
    '''Return the square of provided value.'''
    return value * value
1

There are 1 best solutions below

2
On

You can use F2 and rename the variable. It will rename only, but all the variable instances in the file. When the cursor is on the variable you want to rename, click F2 you will see a prompt like this.

rename variable in VSCode