Tuesday, November 1, 2022

Re: Lowest number of keystrokes to modify part of a line

On 2022-11-01 10:50, 'Ottavio Caruso' via vim_use wrote:
> morse Sun 30/10 22:07[x]
> qrq Mon 31/10 10:19
> Groups Mon 31/10 19:42
>
> See that [x]? That's where the cursor is.
>
> I want to modify the line just below that (starting with qrq),
> remove that timestamp and put a new one.

My first thought is to map a key to do a substitution using
sub-replace-special like

nnoremap Q :s@ \<lt>\zs.*@\=strftime("%a %d/%m/%Y")<cr>

or, if you always do this from the line above, you can add a "+"

nnoremap Q :+s@ \<lt>\zs.*@\=strftime("%a %d/%m/%Y")<cr>

which, while it has more keystrokes initially to create, reduces
the "update the timestamp on the next line" to a single keypress
("Q" in this instance, but whatever you want to map it to).

(also, it looks like your strftime() format string differs from the
format in the existing data, so tweak accordingly)

-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/Y2EhI1wDMVQ4z7tu%40thechases.com.

No comments: