[vim/vim] Better handling of numbers when using Ctrl-A and Ctrl-X (Issue #15033)

10 views
Skip to first unread message

Chris Patuzzo

unread,
Jun 17, 2024, 10:06:16 AM (9 days ago) Jun 17
to vim/vim, Subscribed

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.

Currently, pressing Ctrl-A or Ctrl-X on a really big number, e.g. 99999999999999999999999 causes it to be set to 2^64-1 (or similar) rather than the expected value 100000000000000000000000. This is surprising and could be the source of bugs if used in a macro, for example. The exact value varies between Vim and Neovim but both exhibit the same issue.

Secondly, I have regularly been caught out (and others I have spoken to) by Vim treating words such as article-123 as negative numbers and therefore incrementing to article-122 rather than article-124 which is counter-intuitive. I'm aware you can set nrformats+=unsigned to make Vim to treat all numbers as positive but I still want Ctrl-A on -123 to become -122.

Describe the solution you'd like

  1. Would it be possible for Vim to support big numbers for Ctrl-A and Ctrl-X, or are we limited to 64-bit integers?

  2. Would it be possible to introduce a new setting, perhaps nrformats+=contextual to make Vim first check if there's a space immediately preceding the number (i.e. -123) before treating it as negative number? Otherwise, it would be treated as positive. I suppose unsigned and contextual would be mutually exclusive settings, in that case.

Describe alternatives you've considered
Perhaps we could just document this behaviour if we want to keep it as is because both cases above are a bit surprising.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15033@github.com>

Distobs

unread,
Jun 24, 2024, 10:54:56 AM (2 days ago) Jun 24
to vim/vim, Subscribed

Got the "contextual" format to work with the normal and visual modes. Would like to know chrisbra's take on this issue before sending a PR!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15033/2186774571@github.com>

Reply all
Reply to author
Forward
0 new messages