Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active November 25, 2021 15:42
Show Gist options
  • Select an option

  • Save YumaInaura/6585e10fd96dcf1b0088f20c40cd448e to your computer and use it in GitHub Desktop.

Select an option

Save YumaInaura/6585e10fd96dcf1b0088f20c40cd448e to your computer and use it in GitHub Desktop.

Revisions

  1. YumaInaura revised this gist Aug 21, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions VIM.md
    Original 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)

    ## Command
    ## 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.

    ### Improve. Give some filepath to VIM
    ### 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.

    ### Improve. Use temporary file and STDOUT
    ### Step. Use temporary file and STDOUT

    1. Touch temporary file
    2. Send pbpaste STDIN to VIM
  2. YumaInaura revised this gist Aug 21, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion VIM.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    Put blow line in your rc file ( e.g `~/.bashrc` `~/.zshrc` )

    And restart your shell.
    Restart your shell and hit `pbvim`.

    ```sh
    function pbvim (){
  3. YumaInaura revised this gist Aug 21, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion VIM.md
    Original 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

  4. YumaInaura revised this gist Aug 21, 2018. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions VIM.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Vim—Edit clipboard text directly ( Example using Mac OS pbcopy / pbpaste )
    # 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

    ## Links
    ## 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)
  5. YumaInaura revised this gist Aug 21, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions VIM.md
    Original 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)
  6. YumaInaura revised this gist Aug 21, 2018. No changes.
  7. YumaInaura revised this gist Aug 21, 2018. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions VIM.md
    Original 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 - +"saveas $pbvim_tmp_file"
    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)

    And restart your shell.

    ## 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 - +"saveas some_filepath"
    pbpaste | vim - +"w some_filepath"
    ```

    This shell command execute "vim command" as `:set saveas some_filepath` immediately before editing.
    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
    - 3. Remove temporay file
    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.

  8. YumaInaura created this gist Aug 21, 2018.
    61 changes: 61 additions & 0 deletions VIM.md
    Original 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)