Vim Tips Wiki

Changes: Convert numbers hex/decimal via menu


Back to page

(Remove html character entities)
(merged to 27)
Line 1: Line 1:
#REDIRECT [[Convert between hex and decimal]]
|created=August 18, 2004
|author=Thomas Ramming
Here is a quick way to transform hex numbers to decimal or vice versa.
Visual select the number (no leading '0x' allowed, sorry) and select the menu to transform the number.
You need the calculator 'bc' (standard unix, or cygwin).
vmenu 1.220 PopUp.&nr2hex <Esc>:exec("!echo \\"obase=16;".@*."\\" \| bc -l -q ")<CR>
vmenu 1.220 PopUp.hex&2nr <Esc>:exec("!echo \\"ibase=16;".toupper(@*)."\\" \| bc -l -q ")<CR>
Windows (need something like):
<Esc>:!bash -c " <see exec(...) above plus extra escaping> "<CR>
Use {{script|id=54}} to have a more general solution without using an external program like bc.
Script 54 is just a transformation of numbers, bc can really calculate, work with variables, functions etc.
So what is FAB1DF4 * FF
Just visual mark 'FAB1DF4 * FF' and select 'hex2nr' to see the result.
FAB1DF4 * FF = 67032503820
262872564 * 255 = 67032503820
Also see [[VimTip448]].

Latest revision as of 02:40, October 28, 2009

  1. REDIRECT Convert between hex and decimal

Around Wikia's network

Random Wiki