Jupyterlab - find and replace globally ( all files and in all directories )

922 Views Asked by At

Is there any way to find and replace text string automatically in all folder's files? similar to what we get in sublime text, VS code etc

2

There are 2 best solutions below

0
Michael Kopp On

In JupyterLab you can open a terminal. Depending on the OS you use, you can use the tools from that OS to do the job. On Linux for example you can use find and sed to replace:

find path/to/folder -type f -exec sed -i 's/replace this/with this/g' {} \;

Other than that I do not think that this is a built-in functionality in JupyterLab.

0
krassowski On

You can install jupyterlab-search-replace extension, for example with pip:

pip install jupyterlab-search-replace

and the required ripgrep, for example on Ubuntu:

sudo apt-get install ripgrep

If you use a conda environment you can just install both with:

conda install -c conda-forge jupyterlab-search-replace ripgrep

For up-to-date installation instructions see the GitHub repository of the extension.

This extension requires JupyterLab 3 or newer.

Demonstration