Increase% z hexadecimal with VIM?

Is there a way to increase %zhexadecimal numbers using VIM? I can usually do this by simply doing ctrl + afor normal numbers. But unfortunately, I'm using an old school system that uses %z, and not 0xfor, hexadecimal numbers. I tried

Set nf=hex

But this, unfortunately, only works for 0xhexadecimal numbers. Has anyone come across this before? I did not find much on the google machine.

+4
source share
2 answers

%z; , , % z0f; , ? ( , !), :map <C-p> :call MyIncrement()<CR>

, ; 17 reset ; l:c l:b (, , l:a) .

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 i 0x\e\<C-a>"
      call cursor(l:l, l:a+2)
      silent exe "normal 3x"
      call cursor(l:l, l:c)
    endif
  endif
endfunction
+1

@oobivat:

:map \a Fza0x<ESC><C-a>Fzlxx

\a - ( ):

  • z (Fz)
  • 0x (a0x<ESC>)
  • incremente hexadecimal (<C-a>)
  • delete 0x( Fzlxx)
+1
source

Source: https://habr.com/ru/post/1613910/


All Articles