diff --git a/nvim/.config/nvim/plugin/shell.vim b/nvim/.config/nvim/plugin/shell.vim index af4760e..5c27139 100644 --- a/nvim/.config/nvim/plugin/shell.vim +++ b/nvim/.config/nvim/plugin/shell.vim @@ -31,5 +31,30 @@ function! s:JqScratch() endfunction command! JqScratch call s:JqScratch() +function! GetDecimal() + execute 'normal! viw' + let hex = expand("") + if stridx(hex, "0x") == 0 + let decimal = trim(system("printf '%d\n' " . hex)) + else + let decimal = trim(system("printf '%d\n' 0x" . hex)) + endif + echo decimal + call system('wl-copy ' . string(decimal)) + execute "normal! \e\eb" +endfunction + +function! GetHexaDecimal() + execute 'normal! viw' + let decimal = expand("") + let hex = trim(system("printf '%x\n' " . decimal)) + echo hex + call system('wl-copy ' . string(hex)) + execute "normal! \e\eb" +endfunction + nnoremap j :JqScratch nnoremap s :Shell rg '' % + +nnoremap h :call GetDecimal() +nnoremap H :call GetHexaDecimal()