I just found the very nice markdown-plugin which opens a new tab in browser, displaying the markdown edited in the current vim window.

My question is, is it possible to make it work more like NerdTree for example, where the data will be displayed not in a browser, but in a vim window.

I know NerdTree and its likes are displaying basically text, which is compatible to Vim, but I was hoping that displaying HTML would be possible as well


  • 1
    Vim can display regular text and nothing else (no rich text or graphics). Just like a standard terminal emulator.
    – B Layer
    Sep 12 '21 at 14:16
  • Assuming you've installed links it's just :term links
    – Matt
    Sep 12 '21 at 14:33
  • @Matt I'm not familiar with links. What is it? Can you share a link? Sep 12 '21 at 19:29
  • 1

TL;DR It's not possible to do it as you expect but there is one alternative using text-based web browsers.

First let's understand what this plugin does on a very high level view:

  • A web browser is not able to display a raw markdown file: to see your markdown file in your browser you need to convert it to html and then open this html file in your browser.
  • When you open the html file in the browser you see it formatted (bold titles, formatted lists, etc) because the primary function of your browser is to render html code into graphics.
  • So what the plugin does (most likely, I didn't inspect the sources deeply) when you are editing a markdown file:
    • First it starts a local webserver which will serve your html file
    • When you edit your markdown file it recomputes the resulting html and makes sur the webserver serves this html file. This way you can navigate to (the address of the local webserver) to see the result in a browser
    • It does a bit of additional magic to synchronize your scrolling and some other stuff

This is how you get your preview in a browser. Now you want the rendered graphics in a vim window: This can not be done because vim is able to render text only it can not render graphics. That's why the answer to your question is "No you can't do that"

However there might be a trick: As @Matt suggested some web browsers are text based. This means that they can take a html file and render it as text. This means that you can open a web browser. For example if you open this webpage (which is an html file) in a text-based browser you'll see something like this:

enter image description here

One example of a text-based web browser is links

So if that is good enough for you, you can use the markdown-preview plugin to start the webserver and serve your markdown converted to html file and then you can open the text-based web browser in a vim window.

Also as a final note: The plugin that you linked is deprecated and the author recommends to use the newer version markdown-preview.nvim which is also compatible with Vim, I would encourage you to use this plugin instead unless you are sure that the old version has all the features you need and doesn't have bugs which would impact you.

  • Sadly text based browsers such as links does not cut it for me... I stayed with the regular browser. And as for the deprecated plugin - yeah... Saw that when I actually read the plugin's documentation and I moved to the new one which is indeed nicer. Now a bit of a side question - what needs to be changed so vim could support rendering HTML to graphics? Sep 13 '21 at 15:56
  • 1
    "What needs to be changed so vim could support rendering HTML to graphics?" I would recommend you to read the source code but the short answer is probably "way too many things for anyone to bother doing it" :) Also even if you spent months of work on that I'd be surprised to see Bram merging something which changes Vim so deeply.
    – statox
    Sep 13 '21 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.