Thursday, June 4, 2015

Re: Incrementing and decrementing numbers

Looks like it is signed operation always, you can try these mappings instead:

"Keeping cursor on a number, hit these
nn <c-a> ciw<c-r>=@"+1<cr><esc>
nn <c-x> ciw<c-r>=@"-1<cr><esc>

You can, maybe, write a function to move to the nearest number to mimic native ctrl-a behavior.

Regards,
-Arun

On Thu, Jun 4, 2015 at 6:54 AM Ven Tadipatri <vtadipatri@gmail.com> wrote:
I like the ctrl+a and ctrl+x shortcuts for increasing and decreasing numbers, but I noticed
some peculiar behaviors with dashes (Vim 7.2). If I have a string
  data-2-4
When I go to the '2' and hit ctrl a, it seems to treats it as a negative number, so incrementing it
results in data-1-4 (so apparently -2 became -1)
  But if I have the string
  data.2.4
Now, when I go to the '2' and hit ctrl a, the behavior is as expected, result in data.3.4

Is there some flag to allow ctrl+a to always increment a number and not treat the numbers as positive and negative values, and likewise for ctrl+x?

Thanks,
Ven

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment