0

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
Izaya
  • 1,270
  • 2
  • 13
  • 31

1 Answers1

0

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

tHeSiD
  • 4,587
  • 4
  • 29
  • 49
  • Thank you. That's why I was asking for something similar for multi-cursor selection. But perhaps it's not possible. – Izaya May 13 '21 at 14:48
  • There's this https://stackoverflow.com/a/45277437/400836 , CMD+F, then option+enter to highlight all to edit; Also saw an even shorter way, CTRL+F2 (or in mac) CMD+F2, will. highlight the word all + cursor. – Quang Van Jun 12 '23 at 15:16