Last active
November 25, 2021 15:42
-
-
Save YumaInaura/6585e10fd96dcf1b0088f20c40cd448e to your computer and use it in GitHub Desktop.
Revisions
-
YumaInaura revised this gist
Aug 21, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ function pbvim (){ [ccc/pbvim at master · YumaInaura/ccc](https://github.com/YumaInaura/ccc/blob/master/source/pbvim) ## Steps ### Step. Read text from STDIN by VIM @@ -29,7 +29,7 @@ pbpaste | vim - But in above pattern VIM has no filename so can not save edit. ### Step. Give some filepath to VIM ``` pbpaste | vim - +"w some_filepath" @@ -41,7 +41,7 @@ So you will able to save editing in `some_filepath`. But vim does not send STDOUT edited text. ### Step. Use temporary file and STDOUT 1. Touch temporary file 2. Send pbpaste STDIN to VIM -
YumaInaura revised this gist
Aug 21, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Put blow line in your rc file ( e.g `~/.bashrc` `~/.zshrc` ) Restart your shell and hit `pbvim`. ```sh function pbvim (){ -
YumaInaura revised this gist
Aug 21, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ Put blow line in your rc file ( e.g `~/.bashrc` `~/.zshrc` ) And restart your shell. ```sh function pbvim (){ readonly pbvim_tmp_file=./.pbvim.tmp -
YumaInaura revised this gist
Aug 21, 2018 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Vim—Edit clipboard text directly ( Example using Mac OS pbcopy / pbpaste commands ) ## Ease way @@ -56,7 +56,11 @@ 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 ## Ref - [Read from stdin to new, named, file in vim - Super User](https://superuser.com/questions/421367/read-from-stdin-to-new-named-file-in-vim) - [How to save as a new file and keep working on the original one in Vim? - Stack Overflow](https://stackoverflow.com/questions/4980168/how-to-save-as-a-new-file-and-keep-working-on-the-original-one-in-vim) ## Links - [Medium—imported](https://medium.com/p/2238783e2ad9) -
YumaInaura revised this gist
Aug 21, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -59,3 +59,4 @@ This is a first example of this article. ## Links - [Read from stdin to new, named, file in vim - Super User](https://superuser.com/questions/421367/read-from-stdin-to-new-named-file-in-vim) - [How to save as a new file and keep working on the original one in Vim? - Stack Overflow](https://stackoverflow.com/questions/4980168/how-to-save-as-a-new-file-and-keep-working-on-the-original-one-in-vim) -
YumaInaura revised this gist
Aug 21, 2018 . No changes.There are no files selected for viewing
-
YumaInaura revised this gist
Aug 21, 2018 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,11 +4,13 @@ Put blow line in your rc file ( e.g `~/.bashrc` `~/.zshrc` ) And restart your shell. ``` function pbvim (){ readonly pbvim_tmp_file=./.pbvim.tmp pbpaste | vim - +"w $pbvim_tmp_file" cat "$pbvim_tmp_file" | tr -d "\012"| pbcopy rm -f "$pbvim_tmp_file" @@ -17,8 +19,6 @@ function pbvim (){ [ccc/pbvim at master · YumaInaura/ccc](https://github.com/YumaInaura/ccc/blob/master/source/pbvim) ## Command ### Step. Read text from STDIN by VIM @@ -32,22 +32,22 @@ But in above pattern VIM has no filename so can not save edit. ### Improve. Give some filepath to VIM ``` pbpaste | vim - +"w some_filepath" ``` This shell command execute "vim command" as `:w some_filepath` immediately before editing. So you will able to save editing in `some_filepath`. But vim does not send STDOUT edited text. ### Improve. Use temporary file and STDOUT 1. Touch temporary file 2. Send pbpaste STDIN to VIM 3. Save edited text to temporary file 4. STDOUT from edited temporary file and STDOUT to pbcopy 5. Remove temporay file This is a first example of this article. -
YumaInaura created this gist
Aug 21, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ # Vim—Edit clipboard text directly ( Example using Mac OS pbcopy / pbpaste ) ## Ease way 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](https://github.com/YumaInaura/ccc/blob/master/source/pbvim) And restart your shell. ## Command ### Step. Read text from STDIN by VIM ``` pbpaste | vim - ``` But in above pattern VIM has no filename so can not save edit. ### Improve. Give some filepath to VIM ``` 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. ### Improve. Use temporary file and STDOUT - 1. Touch temporary file - 2. Send pbpaste STDIN to VIM - 3. Save edited text to temporary file - 4. STDOUT from edited temporary file and STDOUT to pbcopy - 3. Remove temporay file This is a first example of this article. ## Versions - VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 7 2018 21:58:18) - Max OS X High Sierra ## Links - [Read from stdin to new, named, file in vim - Super User](https://superuser.com/questions/421367/read-from-stdin-to-new-named-file-in-vim)