Is there a keyboard shortcut in Pycharm for rename a specific variable?
<p>I'm using <strong>Pycharm</strong> for Python coding, and I want to change the name of a <strong>specific variable</strong> all over the code. is there any keyboard shortcut for this operation?</p>

<p>In Matlab I can use <em>ctrl</em> + <em>shift</em>.</p>

<p>For example:</p>

<pre><code>old_name=5
x=old_name*123
</code></pre>

<p>will become:</p>

<pre><code>new_name=5
x=new_name*123
</code></pre>

<p>without the need to change both of the <code>old_name</code> references.</p>

<p>Thanks!</p>

<p>I don't know about a shortcut for this special purpose, but I simply use <kbd>Ctrl</kbd>+<kbd>R</kbd> to replace the old variable names with new ones. You can also set settings such as <em>Match case</em>, <em>Regex</em> or <em>In selection</em>.</p>

<p>Note that this won't work, if you have a variable name including another variable name:</p>

<pre><code>var1 = 0
var1_s = "0"
</code></pre>

<p>Replacing <code>var1</code> to <code>xy</code> would result in :</p>

<pre><code>xy = 0
xy_s = "0"
</code></pre>

<p>But that also forces you to do consistent and clear variable naming.</p>

python python-2.7 keyboard pycharm keyboard-shortcuts