May not be the most efficient way but… I'll accept a "mode" in g:Comment()
as g:Comment(mode: string). Then in the mappings, I'd explicitly map modes
with their strings
vmap \c :<C-U>call Comment("visual")<CR>
*Igbanam*
On Tue, 22 Jul 2025, 10:47 'Russell Shaw' via vim_use, <
[email protected]> wrote:
> 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 [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/vim_use/a3ef458e-d463-4e2c-b109-5342d9e54078%40netspace.net.au
> .
>
--
--
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/CAOmRJrceyj_qeVJ%3DQax6fmOW_K3tPf7juJyNyed%3DktfK_7eeog%40mail.gmail.com.