How to change the variable name all at once?

I know that ctrl + F will find the texts that I want, and I can change variable names accordingly.

However, is there any function or buttons that supports changing all the variable name all at once, as we do in other non-browser based IDEs?

Yes, both the text editor and the notebook viewer in JupyterLab have Find-and-Replace all as an option.
You need to toggle the little drop-down indicator that is to the left of where you enter the search text in order to bring up the ‘Replace’ options.

Here is the text editor in action:

Here is the notebook viewer as you edit cells in action:

If you’d to see what you should be seeing, go here and select ‘Try JupyterLab’.
These examples came from there just now. It is running JupyterLab 3.2.0. If you have a JupyterLab version that is 3 or above, then it is really worth updating.


jupyterlab-lsp has the rename feature too, which will only replace code occurrences*:

*the behaviour will vary depending on the language server you choose.

1 Like

Thank you for your suggestion. “jupyterlab-lsp”, is it a jupyterlab extension? I have visited the github repo page of it, but cannot really figure it out.

Yes, it is a JupyterLab extension.

1 Like

It was you, krassowski, who made the extension! It is an amazing extension and I love it. Thank you for making such a great extension and make it free to use :slight_smile:

1 Like