问题
I'm using Pycharm for Python coding, and I want to change the name of a specific variable all over the code. is there any keyboard shortcut for this operation?
In Matlab I can use ctrl + shift.
For example:
old_name=5
x=old_name*123
will become:
new_name=5
x=new_name*123
without the need to change both of the old_name
references.
Thanks!
回答1:
Highlight your old_name
and hit Shift+F6
回答2:
I don't know about a shortcut for this special purpose, but I simply use Ctrl+R to replace the old variable names with new ones. You can also set settings such as Match case, Regex or In selection.
Note that this won't work, if you have a variable name including another variable name:
var1 = 0
var1_s = "0"
Replacing var1
to xy
would result in :
xy = 0
xy_s = "0"
But that also forces you to do consistent and clear variable naming.
来源:https://stackoverflow.com/questions/39746405/is-there-a-keyboard-shortcut-in-pycharm-for-renaming-a-specific-variable