diff --git a/vim/.vimrc b/vim/.vimrc index 27a5e8e..8358773 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -336,3 +336,24 @@ let g:fzf_colors = \ 'marker': ['fg', 'Keyword'], \ 'spinner': ['fg', 'Label'], \ 'header': ['fg', 'Comment'] } + +" xnoremap c =:'<,'>:w ! base64p + +" Function to base64 encode the exact selected text and replace it without a newline +function! Base64EncodeSelection() + normal! gv"vy + let l:selected_text = getreg('"') + let l:encoded_text = system('echo -n ' . shellescape(l:selected_text) . ' | base64 -w0') + let l:encoded_text = trim(l:encoded_text) + execute "normal! gv\"_c" . l:encoded_text +endfunction +xnoremap be :call Base64EncodeSelection() + +function! Base64DecodeSelection() + normal! gv"vy + let l:selected_text = getreg('"') + let l:encoded_text = system('echo -n ' . shellescape(l:selected_text) . ' | base64 -d') + let l:encoded_text = trim(l:encoded_text) + execute "normal! gv\"_c" . l:encoded_text +endfunction +xnoremap bd :call Base64DecodeSelection()