vimpastebin

How to pastebinit in Vim?


Following Openwest 2015 - Erik Falor I am trying to post a text via pastebinit from vim (and nvim) with:

  1. %!pastebinit -- it cuts all the text of the file, pushes to pastebin and leaves the pastebin link in the file
  2. copy to "a register and "a!pastebinit (or "a!pastebinit -i -) probably pushes to the pastebin, but doesn't show any output (unlike other shell commands)

-- how to do it right?

Can one open a register for editing, like Ctrl+F in commandline mode, which opens command history for executing edited commands?


Solution

  • :%w !pastebinit
    

    will send the whole buffer to pastebinit and echo the url of your paste.

    You can use a range:

    :.w !pastebinit
    :10,24w !pastebinit
    

    Or visual selection:

    vjjj
    :'<,'>w !pastebinit
    

    See :help :w_c.

    You can turn that into a practical custom command with:

    " Mac OS X
    command! -range=% Paste silent execute <line1> . "," . <line2> . "w !pastebinit | tr -d '\\n' | pbcopy"
    
    " Other Unices
    command! -range=% Paste silent execute <line1> . "," . <line2> . "w !pastebinit | tr -d '\\n' | xclip -i -selection clipboard"