The simplest option for this would be to download the RunView plugin from the Vim website and use this. If you let g:runview_filtcmd
be equal to your SendEmail command line, it will take the contents of the current buffer, pipe it to SendEmail and print the output in a separate window. I think this achieves what you need. If you want to use RunView for other stuff, you could omit the g:runview_filtcmd
step and just add this command:
:command! -nargs=* -range=% SendEmail <line1>,<line2>RunView SendEmail -e oneoption -b twooption <args>
and then do:
:SendEmail -u "subject"
or
:'<,'>SendEmail -u "subject"
I haven't tested any of this, but it should work very easily.
If you want to do it manually, you'll probably have to write a function. The way that RunView works is to copy the whole buffer into a register, create a new window, paste the buffer into the end of that window and then filter the new lines through the program. It adds a date/time stamp at the start to separate multiple runs of the same program. This wouldn't be too hard to replicate, but you would probably need a function.
Edit in response to comment:
If you want to send the path as an argument to SendEmail, you could do something like this (I haven't tested this, so it might need tweaking a litle):
command! -nargs=* SendEmailAsAttachment exe '!SendEmail -e oneoption -b twooption -f' expand('%:p') <args>
Note that :exe
concatenates arguments with a space, so calling SendEmailAsAttachment -u "subject"
expands to:
!SendEmail -e oneoption -b twooption -f /path/to/filename.txt -u "subject"
See:
:help expand()
:help :exe