Saturday, September 4, 2021

Re: How to replace pattern with shell command's output using matched pattern

I'm just curious, is the file being otherwise edited in vim?  I usually just use less to view logs, in which case, a command line filter would be more efficient (for me).

If you're writing a report, makes sense to keep it in vim.

On Saturday, September 4, 2021 at 11:23:28 AM UTC-4 Tim Chase wrote:
On 2021-09-04 14:07, Andreas Perstinger wrote:
> Alternatively, without using an external command:
>
> :%s_^\[\(\d\+\)_\="[" . strftime("%c", submatch(1))_

This is much better than the suggestion I gave, keeping it all
internal to vim. To clean it up, I'd tweak it to

:%s/\[\zs\d\+\ze\]/\=strftime("%c", submatch(0))

-tim




--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/bc644ff5-e96a-4204-be18-24bc1c70b90cn%40googlegroups.com.

No comments:

Post a Comment