From 031f2d876b4ddd3237e0f59548084932677f1b77 Mon Sep 17 00:00:00 2001 From: Stefan Friese Date: Wed, 18 Sep 2024 09:51:39 +0000 Subject: [PATCH] added base64 decode and encode through leader be and leader bd --- vim/.vimrc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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()