Sunday, July 20, 2025

Calling a vim9script function with a range

Hi,

In "Comment()", how can i tell if the mapping "\c" was called with a visual
range or not ?

I want to call "Comment()" only once, without resorting to a legacy function,
and without resorting to an intermediate ex command.

I want access to the first and last visual lines, or else the current line (for
non-visual, first==last).

---------------------------------
vim9script

def g:Comment()
echo "a"
enddef

map \c :<C-U>call Comment()<CR>
---------------------------------

--
--
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 visit https://groups.google.com/d/msgid/vim_use/a3ef458e-d463-4e2c-b109-5342d9e54078%40netspace.net.au.

No comments: