On Jan 11, 2014 1:07 AM, "Jacobo de Vera" <[email protected]> wrote: > > On Fri, Jan 10, 2014 at 7:03 PM, Rick Dooling <[email protected]> wrote: > > > >> > This one grabs the buffer contents, converts it to HTML, and sends it to the clipboard for pasting into WordPress or whatever. > >> > >> > " Send Text Through Filter To Clipboard: > >> > " http://vim.wikia.com/wiki/Use_filter_commands_to_process_text > >> > function! MDC() > >> > :redir @+ > >> > " No output file specified so it goes to STDOUT > >> > exe '!pandoc %' > >> > :redir END > >> > endfunction > >> > >> > This morning I was monkeying with using Python in Vim to do this. That also works. Then you can use Python's Markdown module. > >> > >> But does it though? From what I see the line: > >> > >> exe '!pandoc %' > >> > >> Is running pandoc with the *file* open in the current buffer as input, > >> which means you have to have a file and you have to save it in order > >> for it to work. This is similar to what was shown in previous emails, > >> but what I was wondering is whether one can use something similar that > >> uses buffer contents, not file contents. > >> > > > > > if no file is specified with -o in pandoc it goes to STDOUT, and you are using redir to redirect STOUT to the clipboard. At least that's how I understand it. > > > > Another scripting angle, esp. using Python or Ruby is just run the commands, save the file, and tell vim to open the file in a new buffer. > > > > Now that I've been playing, the redirect to the clipboard is actually even more useful, because you can use Marked2 or some other html converter/viewer to check things before loading your html up to go paste. > > > > Rick > > > > Rick, I think you and I are talking about two different things here. I > am talking about the input and you are talking about the output. So > yes, pandoc sends its output to stdout, which is captured by Vim. But > the input, it takes from a file name, which is the value after > replacing '%' on that exe line.
If it is terminal vim output is not captured. In fact command executed with :! gets direct access to the terminal. For capturing output there is system(). > > Say you create a new file, then write some markdown, and, before > saving, you run that function. You'd get nothing, because pandoc > receives, as input, an empty file. Pandoc, and many other programs, > however, support getting their input from stdin. In vim you can send > the contents of the current buffer to a process' stdin, and then the > process' stdout replaces those contents, just like when one does: > > :%!sort > > What I was trying to ask is. How does one send those unsaved contents > to a program without getting them replaced with the output of such > program, but instead get the output in a separate tab? The function > you sent provides a solution for the second part, since it will > redirect output to a variable or a register. Now we are only missing > the first part, which we nearly have, but it uses files, rather than > buffer contents. > > Hope that clarifies my question a little. > > Regards, > > -- > Jacobo de Vera > http://www.jacobodevera.com > @jovianjake > > -- > -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups "vim_use" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
