v:count in mapping gets E492: Not an editor command: count

9 views
Skip to first unread message

Graham Lawrence

unread,
Jul 20, 2020, 2:02:29 PM7/20/20
to vim_use
:h v:count includes the following example
map _x :<C-U>echo "the count is " . v:count<CR>

which works as expected, but using
map :let @n=v:count1<cr> ...

produces E492 etc; and instead I must use
map ;; :<C-U>exe 'let @n=v:count1'<cr> ...

for it to work.

Now I have a number of mappings in alternate .vimrc files that use the 'let' form that now fails, which strongly implies that at one time that method of saving v:count did work.
So is this a recent development? Or have I unwittingly set something in .vimrc that invalidates 'let'? Or is it a vim error that is likely to be corrected by reverting to the old form? Or ...?

Jürgen Krämer

unread,
Jul 21, 2020, 1:20:45 AM7/21/20
to vim...@googlegroups.com
Hi,

Graham Lawrence schrieb am 19.07.2020 um 22:07:
> :h v:count includes the following example
> |
> map _x :<C-U>echo "the count is ".v:count<CR>
> |
>
> which works as expected, but using
> |
> map :let @n=v:count1<cr>...
> |
>
did you really leave out the left-hand-side of the mapping in your .vimrc or is this just a typo in your mail?

> produces E492 etc; and instead I must use
> |
> map ;;:<C-U>exe 'let @n=v:count1'<cr>...
> |
>
> for it to work.
>
> Now I have a number of mappings in alternate .vimrc files that use the 'let' form that now fails, which strongly implies that at one time that method of saving v:count did work.
> So is this a recent development? Or have I unwittingly set something in .vimrc that invalidates 'let'? Or is it a vim error that is likely to be corrected by reverting to the old form? Or ...?

Regards,
Jürgen

Graham Lawrence

unread,
Jul 21, 2020, 2:12:23 PM7/21/20
to vim...@googlegroups.com
You have a very good point there, Jurgen. Somehow now, I have this uncontrollable urge to go baa-aa-aa at the moon.

--
--
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/e18c4134-695a-1d51-1094-926d11ae7481%40googlemail.com.


--
Graham Lawrence
Reply all
Reply to author
Forward
0 new messages