Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code (Mac OS) rename symbol doesn't work

When I right click and try to rename a variable name in Microsoft Visual Studio Code on Mac OS Mojave, it prompts for the new name, I hit enter and nothing happens.

I have Python extension and Latex extension installed.

Usually there are no errors, no nothing.

Sometimes, there's a little box that pops up saying "No Result. No Result".

The python interpreter I selected was a Conda install.

I ensured rope, and pylint were installed.

Expected behaviour: right click > rename symbol > type new name > enter > all instances of variable renamed.

Observed behaviour right click > rename symbol > type new name > enter > variable has same name everywhere, including spot of renaming.

like image 716
Adam B Avatar asked Mar 06 '19 06:03

Adam B


People also ask

How do I rename a Visual Studio MAC code?

Renaming is a common operation related to refactoring source code and VS Code has a separate Rename Symbol command (F2). Some languages support rename symbol across files. Press F2 and then type the new desired name and press Enter. All usages of the symbol will be renamed, across files.

How do I change variable names in Visual Studio Mac?

Show activity on this post. In Visual Studio, when you rename a variable name in its definition, there's a little underline in the last letter so if you hover that, you'll get the option "Rename OldVaribleName to NewVariableName" and so rename all entries in that procedure of that variable.

How do you get symbols in VS Code?

You can navigate symbols inside a file with Ctrl+Shift+O. By typing : the symbols will be grouped by category.


1 Answers

It turns out the solution was simple, but frustrating. To do refactoring in VS Code (at least for python) you need to be in a workspace.

I solved the problem by first closing the open folder I was in:

File > Close Folder.

then navigating to a sub folder of .py file I was editing, and opening it. In my case it was

  1. Click the little document icon in the upper left of screen
  2. In the welcome screen, choose "open folder"
  3. navigate to my desktop folder (where my .py file is)

Now refactoring works as expected

Click on file icon in upper left of screen > in the welcome screen

like image 94
Adam B Avatar answered Sep 22 '22 16:09

Adam B