sponsor Vim development Vim logo Vim Book Ad

ConvertBase.vim : Convert to/from various numeric bases

 script karma  Rating 27/11, Downloaded by 1829  Comments, bugs, improvements  Vim wiki

created by
Christian J. Robinson
script type
This script is basically just three functions:
  ConvertToBase(int, base)
  ConvertFromBase(str, base)
  ConvertBases(str, base1, base2)

And two example functions that are commented out.

The following mappings may also be useful:
" Translate the character under the cursor to a decimal value:
nmap <M-a>d i<C-R>=char2nr(getline(line("."))[col(".") - 1])<CR><ESC>lx
" ... hexadecimal value:
nmap <M-a>h ix<C-R>=ConvertToBase(char2nr(getline(line("."))[col(".") - 1]),16)<CR><ESC>lx
" ... octal value:
nmap <M-a>o i<C-R>=ConvertToBase(char2nr(getline(line("."))[col(".") - 1]),8)<CR><ESC>lx
install details
Source the script or place it in your plugin directory.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ConvertBase.vim 1.0 2001-08-06 5.7 Christian J. Robinson Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.