Execute command in vim
Convert to hex
:%! xxd
Write file with sudo
:%! sudo tee % > /dev/null
Copy buffer to clipboard
See, https://stackoverflow.com/questions/3961859/how-to-copy-to-clipboard-in-vim.
This is my configuration.
I add these aliases to .zshrc,
alias pbcopy="xclip -selection clipboard"alias pbpaste="xclip -selection clipboard -o"
but it didn’t work with raising error
Press ENTER or type command to continue[No write since last change]zsh:1: command not found: pbcopyshell returned 127Press ENTER or type command to continue
I guess vim didn’t read .zshrc file when execute command, maybe using /bin/bash.
So, I change a way.**
I made two scripts, in path ~/Bin,
cat pb* ✔ #!/bin/bashxclip -selection clipboard#!/bin/bashxclip -selection clipboard -o
so, vim can read pbcopy and pbpaste which in PATH, then use
:'<,'>w !pbcopy
in vim command mode, and use CTL+SHIFT+v or pbpaste to paste.
