Search code examples
pythonvariableskeyboard-shortcuts

How do you change variable name and all occurrences of the variable in your code at the same time with a shortcut?


I was wondering if there was a keyboard shortcut to change a variable's name in your code but in a way that I can do it for all of the occurrences of the variable in your code at the same time.

Double-clicking a variable always highlighted the other occurrences so I wondered if it was already suggesting it to me?

enter image description here

I tried searching up shortcuts with no helpful results.


Solution

  • If you're using VS-Code

    Highlight the variable name and press CTRL+Shift+L. Then change your variable's name to whatever you want.

    If you're using Sublime Text

    Alt+F3 on Windows and Linux, or CTRL+Cmd+G on Mac OS.

    If you're using PyCharm

    CTRL+Shift+Alt+J on Windows and Linux, Ctrl+Cmd+G on Mac OS, or Shift+F6 as said by bigkreifer

    I know, I tried to read the documentation, but it's all in dutch and I can't quite understand what it was written, so I'm trying to guess what IDE (Integreated Developing Enviroment, just a fancier text editor) you are actually using