It wasn't about efficiency, I just didn't want to use l2+2 to accomodate 
the shift that would happen if I add before l1 first.


On Tuesday, August 5, 2025 at 4:48:55 PM UTC+10 Russell Shaw wrote:

> On 5/8/25 13:53, Maxim Kim wrote:
> > oops,
> > 
> > instead of getpos() you can use line() of course:
> > 
> > vim9script
> > def g:Comment(line1: number, line2: number)
> >     var l1 = min([line1, line2])
> >     var l2 = max([line1, line2])
> >     append(l2, ["#endif"])
> >     append(l1 - 1, ["assert(0);", "#if 0"])
> > enddef
> > 
> > noremap \cm <cmd>call Comment(line('.'), line('v'))<CR><ESC>
>
> Hi, that one is much more efficient because l2 is appended before l1 :)
>

-- 
-- 
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+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_use/7bd05ab5-5fc5-414c-89f6-cdbe817f8165n%40googlegroups.com.

Reply via email to