On Saturday, November 5, 2022 at 3:13:35 PM UTC-4 [email protected] wrote:
> When I do complex substitutions, I want to see inspect subst,
> undo the substitution, before moving to the next one match
> (gnuemacs has something similar called "recursive-edit")
>
> Eg. my file contains thousands of dates as seconds, and I want to reformat
> the date (but seeing the context around the date)
> :%s,\<\(1[45678]\d\d\d\d\d\d\d\d\)\>,\=system("date +' %F-%H:%M' -d
> @".submatch(1)." "),gc
>
One way to do that would be:
1. /\v<1[45678]\d{8}>
2. qqcgn<C-r>=system("date +' %F-%H:%M' -d @<C-r>" ")<enter><esc>q
3. Use n/N to move between matches; u/C-r to undo/redo; and @q to perform
the change.
(The macro is because, while cgn is actually .-repeatable, the use of the
register inside <C-r>= isn't—the text returned by <C-r>= is considered the
"change".)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/2951d185-eb7f-4014-aeff-f5f055b6268fn%40googlegroups.com.