6

If I decrement my octal number so that it wraps around Vim adds length to this number.
Can the length added be configured?
Example:
00 Decrement with Ctrl-X gives

01777777777777777777777

Even if I have a octal byte
000000000 it gets lengthened to 01777777777777777777777
event though I think it should still be the same byte length after wrapping.

Eg. 01777777

1 Answer 1

5

Solution

(only for decimal, not for octal)

You can simply add unsigned to your nrformat:

:set nrformats+=unsigned

See :help nrformats for more info

Explanation

Because your Vim uses 64bit.

The highest values you can store in 64-bit:


In decimal it is 2^64 - 1 or:

18446744073709551615

If you convert this now to octal, it's this:

01777777777777777777777

And for binary:

0b1111111111111111111111111111111111111111111111111111111111111111


Hope that helps :)

4
  • Thanks for the answer. Is there any way to prevent this from happening? I would class this as a bug as it changes the length of the number being edited in a non-predictable way. Commented Jan 26, 2023 at 12:33
  • I am currently in a restaurant, as soon as I am home I am gonna extend my question and put some resources. And yes that is unexpected behaviour, but also expected and sertainly not a Bug:)
    – Bog
    Commented Jan 26, 2023 at 12:38
  • 1
    @GustavBlomqvist Okay I have updated my answer and found a solution. That at least works for decimal :)
    – Bog
    Commented Jan 26, 2023 at 15:48
  • Hey, would you mind to accept my answer? I really want that 15 points :')
    – Bog
    Commented Aug 15, 2023 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.