Feature sug.: Keep leading Zeros, or "non-octal calculation mode"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Feature sug.: Keep leading Zeros, or "non-octal calculation mode"

Kurt Mielke-2
Keep leading zeros

The Ctrl-a/Ctrl-x, has a feature of assuming octal when a number begins with '0'. I suggest this this feature, so :se klz change the behaviour, and ctrl-a/x only operates on decimal numbers.

So ctrl-a on '007' now turns into '008', Two more gives you '010'.

I realize this does mean that ctrl-x not always reverses ctrl-a as ctrl-a+ctrl-x on '99' leaves you with '099'.

The feature is very useful operating on file names like track009.mp3, and I have never used octal numbers, even when writting assembler it was always decimal or hex.

Enclosed is a patch that implements the ":se klz", I am not sure how attachments works on this list, so it is also available from here: http://lyn.dk/klz.patch

/Kurt Mielke

--
You received this message from the "vim_dev" 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

klz.patch (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Feature sug.: Keep leading Zeros, or "non-octal calculation mode"

Ingo Karkat
On 08-Jul-2010 11:15, Kurt Mielke wrote:
> Keep leading zeros
>
> The Ctrl-a/Ctrl-x, has a feature of assuming octal when a number begins
> with '0'. I suggest this this feature, so :se klz change the behaviour,
> and ctrl-a/x only operates on decimal numbers.
>
> So ctrl-a on '007' now turns into '008', Two more gives you '010'.

Isn't most of it already solved by ":set nrformats-=octal"? Cp :help 'nrformats'.

> I realize this does mean that ctrl-x not always reverses ctrl-a as
> ctrl-a+ctrl-x on '99' leaves you with '099'.

This would be the only difference to existing behavior, but typically those
numbers have a lot of leading 0-padding, so the case where CTRL-X reduces the
width would be rare, and I think it's best handled by manually correcting it
rather than have a new global option.

-- regards, ingo

PS: Don't feel too bad, Vim has so many options; I myself only learned many
through lurking on this list and on the Vim Tips Wiki ;-)

--
You received this message from the "vim_dev" 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