VIM: Adds mappings for url and base64 encoding / decoding

Defines functions for each as autoload functions. I need to look into
weather it would be better to have this as a local function in a plugin.

The function for url encoding was taken from vim-unimpared:
https://github.com/tpope/vim-unimpaired
I don't need all the functionality it provides

The function for base64 encoding was taken from vim-base64:
https://github.com/christianrondeau/vim-base64
although I use it with mappings in the vim-unimpared style

[b and ]b base64 encode and decode respectively
[u url encodes characters that are normally encodede in a url
[U url encodes all characters
]u and ]U both urldecode all encodede characters
This commit is contained in:
Jonathan Hodgson 2020-09-27 00:44:24 +01:00
parent cf0b27ee26
commit 380e2c81c8
2 changed files with 57 additions and 0 deletions

View file

@ -43,3 +43,10 @@ inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
inoremap <C-y> <Esc>:silent s/^/#!\/usr\/bin\/env / <bar> filetype detect<cr>:nohlsearch<cr>o
" alternative: inoremap <C-y> <Esc>:silent exe ".!which <cWORD>" <bar> s/^/#!/ <bar> filetype detect<cr>YpDi
" Mappings for my encoding functions
vnoremap [b :call mine#encoding#wrapper('base64Encode')<cr>
vnoremap ]b :call mine#encoding#wrapper('base64Decode')<cr>
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>