nvim: plugin/shell: Add helper to get decimal & hexadecimal values
This commit is contained in:
parent
384eed0b5c
commit
0dad89e0fb
1 changed files with 25 additions and 0 deletions
|
@ -31,5 +31,30 @@ function! s:JqScratch()
|
|||
endfunction
|
||||
command! JqScratch call s:JqScratch()
|
||||
|
||||
function! GetDecimal()
|
||||
execute 'normal! viw'
|
||||
let hex = expand("<cword>")
|
||||
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("<cword>")
|
||||
let hex = trim(system("printf '%x\n' " . decimal))
|
||||
echo hex
|
||||
call system('wl-copy ' . string(hex))
|
||||
execute "normal! \e\eb"
|
||||
endfunction
|
||||
|
||||
nnoremap <Leader><Leader>j :JqScratch<CR>
|
||||
nnoremap <Leader><Leader>s :Shell rg '' %<Left><Left><Left>
|
||||
|
||||
nnoremap <LocalLeader>h :call GetDecimal()<CR>
|
||||
nnoremap <LocalLeader>H :call GetHexaDecimal()<CR>
|
||||
|
|
Loading…
Reference in a new issue