0

I have a problem piping the current buffer to an external command. Similar questions asked could not solve the problem.

I want to treat the content of the buffer as a string and simply pass it as an argument like this, where %s is the CONTENT of my file:

:!thunderbird.exe -compose body=%s

The usual way of using %w !{cmd} is not working here, because thunderbird doesn't read from STDIN, correct me if this assumption is wrong. (Piping buffer to external command in Vim)

How do I send my buffer content as a string to an external command?

Community
  • 1
  • 1
freeo
  • 3,509
  • 1
  • 22
  • 17

1 Answers1

0

Copying the contents of a whole file into an ex command is going to be difficult because you will need to escape the text. As an alternative I would suggest creating a function to copy the contents of the file to the clipboard and then open a new email and simply paste the contents into the body.

function! Send()
  :%yank +
  :silent !thunderbird.exe -compose
  :redraw!
endfunction

nnoremap <leader>s :call Send()<cr>
Brett Y
  • 7,171
  • 1
  • 28
  • 42
  • I think :redraw is what you want for ^L – Pandu Apr 15 '14 at 02:02
  • I did try using `:redraw`, unfortunately it doesn't have the same effect as `^L`. – Brett Y Apr 15 '14 at 02:15
  • Found the answer here: http://vim.1045645.n5.nabble.com/redraw-vs-Ctrl-L-difference-td1200223.html If you messed up the screen in a way that Vim doesn't know about it, such as with an external command, you need to use ":redraw!". Although now that I re-read `:h :redraw` it's there too. doh. – Brett Y Apr 15 '14 at 02:36