73

There's an option in Jupyter Notebooks where you can select some cells, and then hit F, which opens up a Find & Replace feature.

This shortcut doesn't work in Jupyter Lab. It's not in the Commands list and it's not in the Edit Menu (there is only Find -- and Find Next and Find Previous). Nor can I find a global (not specific to a cell selection) Find & Replace feature.

Does this feature exist? I've found old mentions of it on the internet -- has it been removed? I'm using Jupyter Lab version 1.2.3.

1
  • Simply Command+F for OSx, or Control+F in Windows. It will prompt find, click small arrow (as in accepted answer). Oct 13, 2020 at 20:34

3 Answers 3

132

The Find & Replace feature was not removed, but the way it is named in the menu (simply Find...) and the UI which requires the user to click on a small arrow to access it may be confusing. Please see the GIF below which demonstrates how to use the search & replace feature:

enter image description here

If you need a slightly more powerful refactoring tool (i.e. distinguishing the variable scopes) you may want to check out my jupyterlab-lsp project which now includes support for the rename action (see here for a demonstration GIF, but please install a newer version, not the tag linked).

10
  • 10
    Got it, thank you! I can use Jupyter Lab again. This is pretty bad UI in my opinion, I think most users will miss this. Changing the toggle from an arrow to a "replace" icon, or just having replace toggled on by default, would be much better.
    – Denziloe
    Jan 13, 2020 at 14:36
  • 2
    Actually you can also press "Ctrl+F" to enable the process above.
    – Jeremy
    May 27, 2020 at 12:34
  • 1
    @linello there is an ongoing work to make it possible: github.com/jupyterlab/jupyterlab/pull/10067
    – krassowski
    Apr 18, 2021 at 10:57
  • 8
    "Confusing"? How about "virtually invisible"?
    – Emy
    May 6, 2021 at 13:34
  • 1
    Please help JupyterLab devs improve the situation by chiming in this thread discussing usability of find-and-replace function. Please give thumbs up to solutions that you like, and suggest new solutions (but please avoid comments like "me too" to keep the discussion easier to read).
    – krassowski
    May 7, 2021 at 12:04
3

I am not sure if the original question was answered correctly. If I were to find and replace in only a selected cell, the top rated solution doesn't seem to work (in JupyterLab). The desired result is obtained by clicking on the ... button in the F&R menu. Check the attached snippet.enter image description here

2
  • 1
    Of note in 4.0 ... icon was replaced with a filter (funnel) icon and moved inside the text field as are other buttons.
    – krassowski
    Dec 13, 2023 at 11:12
  • Now why did Jupyterlab have to go and ruin a good system. Mar 8 at 20:40
1

It can be easily done using keyboard in Jupyter as well.

Step 1: If you are inside any code block/cell, press Esc.

Step 2: Press F

Gif for illustration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.