ShowMultiBase : Display a number in binary, octal, decimal and hexadecimal formats
script karma |
Rating 28/10,
Downloaded by 1062 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Lajos Zaccomer |
|
script type |
utility |
|
description |
This is a very simple script to display a number in all or some of binary, octal, decimal and hexadecimal formats at the same time.
There are several existing converter scripts available, which you might want to check:
- vimscript #238 : Function to output a number as HEX
- vimscript #1538 : Convert from base(2,8,10,16) to base(2-32). Also character to html entity.
- vimscript #54 : Convert to/from various numeric bases
The motivation of this script is a bit different, however. I often have to read logfiles with hexdumps and numbers with altering bases. Therefore, I want to see the binary, decimal and hexadecimal representations at the same time to help easier reading of these logfiles and to avoid using an external calculator as much as possible. In addition, I wanted to have more control over how the numbers are displayed that I can reuse the displayed numbers in e.g. reports.
E.g, with the default settings, executing the :ShowMultiBase command, while the cursor is on the number 1234, you'll have the following output: b0100 1101 0010 == 02322 == 1234 == 0x04d2
If the number is e.g. hexadecimal, you can override the autosensed base (10) with :ShowMultiBase 16
The conversion utility functions are also available, but if you need a general conversion function, I recommend using vimscript #54.
There are several display configurations (e.g: bases to show, prefix usage, segmentation etc.), for details see the comments in the script!
Syntax: :ShowMultiBase [base [number]]
If 'number' is not specified, the number under the cursor is taken as input. If 'base' is not specified, it is autosensed. If 'number' is given, 'base' must be also given, but 0 may be used to autosense.
The following mappings are created by default:
\= Display the number under the cursor with autosensed base in the configured bases
\b= Display the binary number under the cursor in the configured bases
\o= Display the octal number under the cursor in the configured bases
\d= Display the decimal number under the cursor in the configured bases
\h= Display the hexadecimal number under the cursor in the configured bases
|
|
install details |
Copy showmultibase.vim to your plugin folder (see http://vimdoc.sourceforge.net/htmldoc/options.html#%27runtimepath%27 to find out about where it is located on your OS)!
If you do not need the default mappings, add the following in your vimrc file and define your choice: let g:ShowMultiBase_UseDefaultMappings = 0
|
|
script versions (upload new version)
Click on the package to download.
showmultibase.vim |
1.1 |
2020-03-11 |
8.0 |
Lajos Zaccomer |
- selection support
- Ian Munsie bugfix: Oct/Hex/Dec FillSegment, SegmentSize configuration fix for Register and Display |
showmultibase.vim |
1.0 |
2010-09-26 |
7.0 |
Lajos Zaccomer |
Save results in registers. Independent configuration of parsing, display and register formats (sorry, backward incompatible). |
showmultibase.vim |
0.2 |
2010-08-29 |
7.0 |
Lajos Zaccomer |
- Mun Johl reported problem with 32< bit numbers. Fixed with using float instead of number, so the handled range is considerably increased and limited only by VIM's float precision (see :help floating-point-precision).
- Fixed removal of leading zero digits
- Mandatory leading 1 in binary removed
- Default binary display segment size changed from 4 to 8 |
showmultibase.vim |
0.1 |
2010-04-21 |
6.0 |
Lajos Zaccomer |
Initial upload |
ip used for rating: 18.191.216.163
|