Nice tip - I love the <cWORD> approach to a lot of things. One limitation is <cWORD> uses vi's word selection. If my secret is a multiline certificate, the contents of a yaml file, or has special characters this won't work.
If you want to visually select the text to pass to an external program, by default vim passes whole lines (e.g. :'<,'> ! base64) , but vis.vim plugin might help (e.g. :'<,'>B ! base64).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice tip.
For a bit more convenience (so you don't have to edit or move the text to a new line):
:help <cword>
and:help <cWORD>
for more informationFor even more convenience, this can be converted into a reusable function:
Now, you can call it with
:call B64ify()
Lastly, you can map this function to a command and/or keybinding for maximum convenience:
This can also be reversed very easily by copying the function and replacing
base64
withbase64 -d
.Here is a final demo:
The final config:
Nice tip - I love the
<cWORD>
approach to a lot of things. One limitation is<cWORD>
uses vi's word selection. If my secret is a multiline certificate, the contents of a yaml file, or has special characters this won't work.That's true.
If you want to visually select the text to pass to an external program, by default vim passes whole lines (e.g.
:'<,'> ! base64
) , but vis.vim plugin might help (e.g.:'<,'>B ! base64
).