Tuesday, September 27, 2022

Re: Bugs in visual mode marks?



вт, 27 сент. 2022 г., 22:33 Lifepillar <lifepillar@lifepillar.me>:
Source this script:

    vim9script

    def g:Select(): list<string>
      const lnum1 = getpos("'<")[1]
      const lnum2 = getpos("'>")[1]
      return getline(lnum1, lnum2)
    enddef

    vnoremap <leader>x <cmd>echo Select()<cr>

Then select some line(s) and type \x. What I would expect (and what
I think Vim used to do up to recently, unless I am missing something) is
that the *currently* selected lines are echoed. Instead, the
*previously* selected lines are printed. Can you reproduce it? Is it
a bug?

Tested with Vim 9.0.611.

Thanks,
Life.

--
--
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/tgvj5t%24rbc%241%40ciao.gmane.io.

You're using cmd token that doesn't switch the modes. The effect is that as long as you're in visual mode the < and > marks are not updated. This is the way how it works and always worked.

Call getpos("v") instead, or change cmd to colon. See also :h line()

Kind regards,
Matvey

--
--
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/CAFsTB%2B%2BqLqZEYY2_9rJA7BCBceS7XcieiL2aXK-7JZQgJT0P0w%40mail.gmail.com.

No comments: