observablehq / feedback

Customer submitted bugs and feature requests
42 stars 3 forks source link

Improve string replacement workflow within a cell #424

Closed mootari closed 9 months ago

mootari commented 2 years ago

Is your feature request related to a problem? Please describe.

At the moment replacing all occurrences of a string within a single cell feels overly complicated:

  1. The author has to open the find/replace modal.
  2. If the author had selected a search string in their code, it will only be prefilled in the search field if the search panel was opened via the keyboard shortcut.
  3. The search will start at the top of the notebook, so the author will have to identify the cell again that they had focused earlier.
  4. Each replacement creates a new notebook version, inflating the overall number of versions.

Describe the solution you'd like

When doing replacements within a cell I'd like to avoid the search panel altogether. Instead I'd like to have a shortcut that adds a cursor to each highlighted occurrence of the selected string (highlighted in green). This would allow me to edit all occurrences simultaneously, without having to add cursors one by one.

Alternatively, a better integration with the search panel:

galopin commented 9 months ago

Any plan to implement a "Selected cells" option? That would be handy 😉

mootari commented 9 months ago

A few months back Observable added a shortcut to select multiple occurrences of a string. My workflow has since been to select the string that I want to replace, then select all instances of the string in the cell by repeatedly pressing cmd+d, and finally replace all instance via multi-cursor editing.