Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<C-a> increment does not work at 07 #6693

Open
mloo3 opened this issue Jun 3, 2021 · 4 comments
Open

<C-a> increment does not work at 07 #6693

mloo3 opened this issue Jun 3, 2021 · 4 comments
Labels
Milestone

Comments

@mloo3
Copy link

mloo3 commented Jun 3, 2021

Describe the bug
Using the key sequence C-a I expect the count to increment, but at 07 it does not increment to 08

To Reproduce
Steps to reproduce the behavior:

  1. Write 07
  2. Press C-a
  3. 010 is shown

Expected behavior
08 should be shown, because that is the next increment of 07

  • Extension (VsCodeVim) version: v1.20.3
  • VSCode version: 1.52.1
  • OS: big sur 11.4

Additional context
Add any other context about the problem here.

@J-Fields J-Fields added this to the Backlog milestone Jun 4, 2021
@J-Fields
Copy link
Member

J-Fields commented Jun 4, 2021

Thanks - this is because we're interpreting 07 as octal, but that should only be done if nrformats includes octal, which it apparently doesn't by default

@J-Fields J-Fields changed the title C-a increment does not work at 07 <C-a> increment does not work at 07 Oct 14, 2021
@yyykt
Copy link

yyykt commented Mar 2, 2022

nrformats defaults to "bin,octal,hex" in vim, but set to "bin,hex" in defualts.vim as well as in many .vimrc, I guess, since octal numbers are not that useful.

'nrformats' 'nf' string (default "bin,octal,hex",
set to "bin,hex" in |defaults.vim|)
local to buffer
This defines what bases Vim will consider for numbers when using the
CTRL-A and CTRL-X commands for adding to and subtracting from a number
respectively;

It seems currently VsCodeVim treats numbers prefixed with 0x, 0 as hexadecimal, octal respectively, i.e. works as nrformats=octal,hex is set, and does not have a setting to change this yet. It would be nice to implement nrformats option, and maybe exclude octal from default.

https://github.com/VSCodeVim/Vim/blob/84dbe5fccb0537f5321aa47f12294eb78a06c564/src/common/number/numericString.ts

Many people would expect the next increment of 07 to be 08, not 10.

@amane-uehara
Copy link

amane-uehara commented Apr 15, 2022

@yyykt
I'm also worried about the same problem.

The current version of VSCodeVim does not have nrformats option.
To realize set nrformats= setting on VSCodeVim, we have no choice but to add the following dirty hack in the settings.json. 😢

"vim.normalModeKeyBindingsNonRecursive": [
    {
        "before": ["<C-a>"],
        "after": ["w", "B", "i", "1", "<Esc>", "<C-a>", "w", "B", "x"]
    },
    {
        "before": ["<C-x>"],
        "after": ["w", "B", "i", "1", "<Esc>", "<C-x>", "w", "B", "x"]
    }
]

@eduardomezencio
Copy link

eduardomezencio commented Jun 17, 2022

<C-a> behaves the same in vim, changing 07 to 010, so this is not a bug in VSCodeVim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants