Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "find and replace" text?

Tags:

jupyter-lab

I see there is such command in the Edit menu tab, but is dim grey, both if I am inside a code tab and if I am outside it, as you can see in the attached screenshot. How can I perform such operation? Screenshot of the issue

like image 226
Vincenzo Lavorini Avatar asked Jul 23 '18 13:07

Vincenzo Lavorini


People also ask

How do I find and replace only selected text?

Method 1: Utilize “Find and Replace” Feature in a Selection Firstly, select target text. Secondly, press “Ctrl+ H” to open “Find and Replace” box. Next enter the finding text in “Find what” text box and the replacing text in “Replace with” box. Then click “Replace All” button.

What is the Find and Replace command?

Find and Replace helps you to find words or formats in a document and can let you replace all instances of a word or format. This is particularly handy in long documents. To use Find and Replace, use the shortcut Ctrl+H or navigate to Editing in the Home tab of the ribbon, then choose Replace.


2 Answers

UPDATE:

with the latest version of Jupyter lab (>1.1.4) this function is added!

Just click "Find", below the "Edit" menu: a contextual window will appear at the top right of the notebook.

There you click on the small arrow at the left side of the text field, and the "replace" function appear.

OLD ANSWER (still good anyway):

At the end, I found this solution, but it's only for those who know how to use VIM, the text editor.

I installed an extension, jupyterlab-vim, and so I can use VIM commands for search and replace text.

This appears to be an overkill as solution, but for VIM lovers (like me) using many VIM commands in Jupyter Lab is just fabulous.

like image 85
Vincenzo Lavorini Avatar answered Oct 20 '22 02:10

Vincenzo Lavorini


A solution will be to:
sed -i "" 's/oldword/newword/g' mynotebook.ipynb

Found here: Is there a way to default to "Replace in all cells" in the "Find and Replace" in jupyter?

like image 39
BND Avatar answered Oct 20 '22 02:10

BND