VIM: adds hex encoding and decoding
This commit is contained in:
parent
c94fb3a761
commit
be84812aaa
2 changed files with 15 additions and 0 deletions
|
@ -12,6 +12,19 @@ function! mine#encoding#base64Decode(text) abort
|
|||
return substitute(system('base64 --decode --ignore-garbage --wrap=0', a:text), '\n$', '', 'g')
|
||||
endfunction
|
||||
|
||||
" hex encodes text
|
||||
" It relies on the executable xxd
|
||||
function! mine#encoding#hexEncode(text) abort
|
||||
return substitute(system('xxd -p', a:text), '\n$', '', 'g')
|
||||
endfunction
|
||||
|
||||
" base64 decodes text
|
||||
" It relies on the executable base64 which should be installed on most unix-y
|
||||
" systems.
|
||||
function! mine#encoding#hexDecode(text) abort
|
||||
return substitute(system('xxd -r -p', a:text), '\n$', '', 'g')
|
||||
endfunction
|
||||
|
||||
" Url encodes characters that are normally encoded in urls
|
||||
" Taken from https://github.com/tpope/vim-unimpaired/blob/master/plugin/unimpaired.vim
|
||||
function! mine#encoding#urlEncode(text) abort
|
||||
|
|
|
@ -50,3 +50,5 @@ vnoremap [u :call mine#encoding#wrapper('urlEncode')<cr>
|
|||
vnoremap ]u :call mine#encoding#wrapper('urlDecode')<cr>
|
||||
vnoremap [U :call mine#encoding#wrapper('urlEncodeAll')<cr>
|
||||
vnoremap ]U :call mine#encoding#wrapper('urlDecode')<cr>
|
||||
vnoremap [h :call mine#encoding#wrapper('hexEncode')<cr>
|
||||
vnoremap ]h :call mine#encoding#wrapper('hexDecode')<cr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue