Put blow line in your rc file ( e.g ~/.bashrc ~/.zshrc )
function pbvim (){
readonly pbvim_tmp_file=./.pbvim.tmp
pbpaste | vim - +"saveas $pbvim_tmp_file"
cat "$pbvim_tmp_file" | tr -d "\012"| pbcopy
rm -f "$pbvim_tmp_file"
}
ccc/pbvim at master · YumaInaura/ccc
And restart your shell.
pbpaste | vim -
But in above pattern VIM has no filename so can not save edit.
pbpaste | vim - +"saveas some_filepath"
This shell command execute "vim command" as :set saveas some_filepath immediately before editing.
So you will able to save editing in some_filepath.
But vim does not send STDOUT edited text.
-
- Touch temporary file
-
- Send pbpaste STDIN to VIM
-
- Save edited text to temporary file
-
- STDOUT from edited temporary file and STDOUT to pbcopy
-
- Remove temporay file
This is a first example of this article.
- VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 7 2018 21:58:18)
- Max OS X High Sierra