all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* TIL about string-rectangle
@ 2020-12-30 20:59 Skip Montanaro
  2020-12-30 21:37 ` Tim Landscheidt
  2020-12-30 21:43 ` Drew Adams
  0 siblings, 2 replies; 13+ messages in thread
From: Skip Montanaro @ 2020-12-30 20:59 UTC (permalink / raw)
  To: Help GNU Emacs

I needed to replace the first comma on each line of a CSV file so I
could more conveniently sort by the first field (date, arranged as
MM/DD/YYYY). After a bit of fussing around, I got it squared away with
query-replace-regexp, did my sort, then needed to revert the
replacement text back to comma. Unfortunately, there were a few other
instances of the replacement text elsewhere in the file which caused
problems. (If I'd had my thinking cap on I would have checked before
doing the original replace, but it seems I was wearing my dunce
cap...) Poking around for help from Emacs against a future need, I
discovered replace-rectangle, which turns out to be an alias for
string-rectangle (bound to C-x r t). It looks to be quite handy when
you need to replace text within a rectangle. It's sort of (but not
quite) like narrow-to-region + query-replace(-regexp)?. It doesn't
query for a string to replace. It simply replaces the rectangle's
contents with the given string on each line.

Kinda cool,

Skip



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-12-31 14:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-30 20:59 TIL about string-rectangle Skip Montanaro
2020-12-30 21:37 ` Tim Landscheidt
2020-12-30 22:11   ` Skip Montanaro
2020-12-31  8:03     ` Yuri Khan
2020-12-31 10:21       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-31 12:44       ` Skip Montanaro
2020-12-31 14:32     ` Tim Landscheidt
2020-12-30 21:43 ` Drew Adams
2020-12-30 22:08   ` Skip Montanaro
2020-12-30 23:11     ` Drew Adams
2020-12-30 23:23       ` Drew Adams
2020-12-30 23:24       ` Skip Montanaro
2020-12-31  7:15         ` Sivaram Neelakantan

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.