How to execute ‘base64 --decode’ on selected text in Vim?

后端 未结 5 2087
北恋
北恋 2021-02-06 23:58

I’m trying to execute base64 --decode on a piece of text selected in Visual mode, but it is the entire line that seems to be passed to the base64 comma

5条回答
  •  無奈伤痛
    2021-02-07 00:55

    Base64 encode/decode visual-selected region in buffer and clipboard, put this in ~/.vimrc, and use F2 to encode selection, and F3 to decode selection

    " 1. base64-encode(visual-selection) -> F2 -> encoded base64-string
    :vnoremap  c=system("base64 -w 0", @")
    
    " 2. base64-decode(visual-selection) -> F3 -> decoded string
    :vnoremap  c=system("base64 -d", @") 
    

提交回复
热议问题