Thursday, January 9, 2014

Re: convert markdown to html in new tab

On Thursday, January 9, 2014 11:26:15 AM UTC-6, Rick Dooling wrote:
> On Thursday, January 9, 2014 10:42:47 AM UTC-6, Rick Dooling wrote:
> > Dear Vim Scripters:
> >
> > I know how to run external commands and send the output to new files and such, but I'm wondering if a Vim scripter can help me do something that has to be a common task.
> >
> > Assume I have a buffer open in Vim called file.markdown
> >
> > I want to run my external markdown processor of choice, say pandoc, on the contents of that buffer and have it appear in a new tab called file.html.
> >
> > In other words I don't want a filter to replace the markdown. I want to run the external command and have the output placed in a new appropriately named buffer in a new tab.
> >
> > THANK YOU
> >
> > Rick
>
> Thank you,
>
> I shall investigate execute!

Quite an education! Still learning Vim. I mainly just write in it. Very little vim scripting.

This works inside Vim on the command line

:execute "!pandoc % -o html" | :tabe %:t:r.html

But I could not map it. I would get weird errors about using :p:h.

So I did this instead.


function! MD()
exe "!pandoc % -o html"
exe ":tabe %:t:r.html"
endfunction

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: