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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_use/02fb06f8-a58b-409f-bf8c-706614e31c3a%40gmail.com.

Reply via email to