I’m sure you’ve found yourself in this situation: you want to edit something, but in multiple places, and at the same time. You’re busy; you don

Combobulate: Bulk Editing Tree-Sitter Nodes with Multiple Cursors

submited by
Style Pass
2024-09-19 11:00:05

I’m sure you’ve found yourself in this situation: you want to edit something, but in multiple places, and at the same time. You’re busy; you don’t want to repeat yourself, and this is the twenty-first century and we do have the technology to do this!

I’ve talked about this too-common problem before: multi-occurrence editing with iedit is one such package; the ubiquitous, and excellent, multiple cursors package is another common one.

Editing multiple occurrences either simultaneously or in sequence is not a new invention. Good, old C-M-% (M-x query-replace-regexp) is sometimes the right choice if you can capture your matches and desired replacements with a regular expression. If that approach does not work, then why not reach out and touch a bunch of stuff with multiple cursors? If you dislike multiple cursors, you can confect a fancy keyboard macro to do the work instead (sadly, the fans of keyboard macros are far too occupied to join us right now, as they are busy trying to re-record or edit the macro steps so it works properly.)

No matter the tool, you’re still limited by your ability to collect the right places to edit. These tools can in principle drop cursors anywhere you want them to, but the problem is that outside of a handful of obvious things (same column offset on each line; each word or symbol matching something; the cadence of text using forward-word; etc.) you must compel these tools to place the cursors where you want them to, and that is often manual, verging on tedious, and not always possible.

Leave a Comment