5

I came across this problem today: I had a table with many entries and wanted to perform a text substitution (normal text substitution was sufficient as I hardly ever need regex text substitutions) in all cells of a single column. I ended up pressing y and n many times, instead of just ! as it would've been had I had a way of restricting the text substitution (I used M-% / query-replace).

What's the best way of performing this task?

1
  • See region-extract-function which is respected by query-replace. The tricky part is to get the buffer-positions of the table slice's rows.
    – politza
    Sep 26, 2018 at 20:07

2 Answers 2

3

You can select the column as a rectangular region using C-x SPC (rectangle-mark-mode) and then M-% (query-replace) will be limited to that rectangle.

1

You can transpose the table with org-table-transpose-table-at-point, then select the relevant row (which used to be a column).

Narrow to region, replace-string, widen, and transpose again.

Note that you may lose hlines when transposing.

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.