Increment %z hex numbers with VIM? -
is there way increment %z
hex numbers vim? typically can doing ctrl + a
normal numbers. unfortunately using old school system uses %z
rather 0x
denote hexadecimal numbers. i've tried
set nf=hex
but sadly works 0x
hex numbers. come across before? haven't found on google machine.
i don't know %z
prefix; tried quick , dirty function increment numbers %z0f; want? should able add mapping (but not since used in function!) :map <c-p> :call myincrement()<cr>
of course should customize according needs; line 17 reset position of cursor after incrmeenting; may want replace l:c
l:b
(or maybe l:a
) , choose most.
function! myincrement() let l:l = line(".") let l:c = col(".") let l:a = 0 let l:b = 0 let l:s = search('%z[0-9a-f]\+', 'bcw',l:l) if l:s == l:l let l:a = col(".") let l:s = search('%z[0-9a-f]\+', 'ecw',l:l) let l:b = col(".") if ((l:a<=l:c)&&(l:c<=l:b)) call cursor(l:l, l:a+2) silent exe "normal 0x\e\<c-a>" call cursor(l:l, l:a+2) silent exe "normal 3x" call cursor(l:l, l:c) endif endif endfunction
Comments
Post a Comment