strange behaviour with ctrl+A (increment)

9 views
Skip to first unread message

eNG1Ne

unread,
Feb 19, 2012, 11:01:51 AM2/19/12
to vim_use
Something odd going on here, and I don't understand: I thought I
remembered how to increment numbers, but it seems not :-{

Here's two lines from a file I'm working on
bar // 04
bar // 05

If I place the cursor on any digit and press just ctrl+A, I get the
expected results
bar // 04
bar // 05

But I actually want to add 59 to each number. So, I put the cursor
first on the 4 and then on the 5; each time, I enter 59 ctrl+A

Result:
bar // 0100
bar // 076

(and by the way - what should I be looking for with :help? :help
increment gives me "E149: Sorry, no help for increment)

Tony Mechelynck

unread,
Feb 19, 2012, 11:19:39 AM2/19/12
to vim...@googlegroups.com, eNG1Ne

See
:help CTRL-A
where you'll find an explanation of how the behaviour of Ctrl-A
increment and Ctrl-X decrement is influenced by the 'nrformats' option.


Best regards,
Tony.
--
You will think of something funnier than this to add to the fortunes.

Taylor Hedberg

unread,
Feb 19, 2012, 11:21:23 AM2/19/12
to vim...@googlegroups.com
The leading zero in your numbers makes Vim treat them as octal, which
I'm guessing you don't intend.

See `:help CTRL-A` and `:help 'nrformats'`.

signature.asc

eNG1Ne

unread,
Feb 20, 2012, 6:11:27 AM2/20/12
to vim_use
:help {keystroke} - now that's worth knowing about!

and the idea of octal had never even crossed my mind! I'll a) check it
in vim; b) avoid adding the leading zeros when setting up the files in
the spreadsheet.

Thanks!
Reply all
Reply to author
Forward
0 new messages