increment a binary number

Showing 1-3 of 3 messages
increment a binary number guitou Foujanet 6/16/09 7:46 AM
Hello ,

I have started to use VIM 1 month ago and I think I start to
understand the philosophy of this editor.
But I have a problem, I am sure that there is a solution. My problem
is the following: I would like to increment a binary number. For
example, I would like to increment 00000001 -> 00000010 -> 00000011
and so on...

But the key Ctrl-A increment a decimal number, and I don't find the
method to increment a binary number.

And after that, I would like to use a macro to increment a number from
2^0 to 2^8 for example.

Thank you,

Guitou
Re: increment a binary number Andy Wokula 6/16/09 12:07 PM
guitou Foujanet schrieb:

See attached plugin, it is a continuation of the
"bin2hex, hex2bin availble in VIM?" thread a few days ago.

"Help" is in the comments to the code.

If you're not used to folding, type  zi  to toggle folding on and off.

Source the script:
    :h :so

To enable it permanently, put it in the plugin folder ...

Default keys are <Leader>ba  and  <Leader>bx  to increment/decrement a
binary number, both accept a count.
    :h <Leader>


HTH,
Andy
--

Re: increment a binary number Charles Campbell 6/25/09 7:43 AM
The latest version of visincr (a plugin) supports production of binary
incremented lists.

0
0
0
0
0

Use ctrl-v to select the column, then press  :IB.  The result:

0
1
10
11
100

Same, but use :IIB:  (this is right-justified, but variable-width fonts
won't work as well to show this)

  0
  1
 10
 11
100

Want zero-fill?  Try the same with :IIB 1 0  (increment by one, fill
with zero, right-justified):

000
001
010
011
100

If you want visincr, you can get it from my website:
http://mysite.verizon.net/astronaut/vim/index.html#VISINCR .

Regards,
Chip Campbell