Bugs in visual mode marks?

8 views
Skip to first unread message

Lifepillar

unread,
Sep 27, 2022, 2:49:21 PM9/27/22
to vim...@googlegroups.com
Has something changed recently in the way Visual mode marks are handled?
I have a couple of functions using '<, '> and the like and they have
started misbehaving recently. Today, I checked the value of getpos("'>")
after selecting some text, and got:

[0, 15, 2147483647, 0]

This using Vim 9.0.493 on an M1 Mac. I am investigating the problem, but
I am curious to know whether it is a known (and perhaps solved) issue.

Thanks,
Life.


Lifepillar

unread,
Sep 27, 2022, 2:57:03 PM9/27/22
to vim...@googlegroups.com
On 2022-09-27, Lifepillar <lifep...@lifepillar.me> wrote:
> Today, I checked the value of getpos("'>") after selecting some text,
> and got:
>
> [0, 15, 2147483647, 0]

Now I have seen that the large number is expected. I will try to make
a reproducible example of my issue.

Life.

Lifepillar

unread,
Sep 27, 2022, 3:33:30 PM9/27/22
to vim...@googlegroups.com
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.

M

unread,
Sep 27, 2022, 3:50:36 PM9/27/22
to vim...@googlegroups.com


вт, 27 сент. 2022 г., 22:33 Lifepillar <lifep...@lifepillar.me>:
--
--
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+u...@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

Lifepillar

unread,
Sep 27, 2022, 4:08:42 PM9/27/22
to vim...@googlegroups.com
On 2022-09-27, M <matthew...@gmail.com> wrote:
> 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.

Aha, that's it! In fact, I have switched to use <cmd> when I have
migrated to Vim 9 script. Somehow I thought it was a substitute for
:<c-u>, but there are other differences.

Thanks,
Life

Reply all
Reply to author
Forward
0 new messages