Sebbene per lo più concordi con il commento di @romainl (il markdown è stato reso abbastanza esplicito da non aver bisogno di un'anteprima), puoi farlo in diversi modi:
[OSX / Unix] Il plugin di markdown istantaneo è una soluzione. Devi avere node.js installato e usare il seguente comando:
[sudo] npm -g install instant-markdown-d
È inoltre necessario avere i pacchetti xdg-utils, curle nodejs-legacyinstallato.
Con ciò quando apri un buffer markdown, una pagina html verrà aperta nel tuo browser web e vedrai le modifiche in tempo reale.
[Unix] Questa risposta suggerisce di usare il programma di markdown di daringfireball .
Una volta scaricato, puoi usare il seguente comando per vedere il file in lynx :
./Markdown.pl ~/testfile.markdown | lynx -stdin
Potresti usarlo in un comando Vim con qualcosa del genere:
:!./Markdown.pl % | lynx -stdin
[Unix] Un altro plugin che potrebbe essere utile è l' anteprima di vim che sembra avere alcune dipendenze ma dovrebbe funzionare su file markdown, rdoc, textile, ronn e rts.
[Windows / OSX] Finalmente l'utente github natesilva ha fatto un'ottima idea che richiede solo il markdowncomando nel tuo percorso. Una volta ottenuto lo script, lo script ,pdovrebbe aprire il markdown nel browser predefinito.
"
" While editing a Markdown document in Vim, preview it in the
" default browser.
"
" Author: Nate Silva
"
" To install: Place markdown.vim in ~/.vim/ftplugin or
" %USERPROFILE%\vimfiles\ftplugin.
"
" To use: While editing a Markdown file, press ',p' (comma p)
"
" Tested on Windows and Mac OS X. Should work on Linux if you set
" BROWSER_COMMAND properly.
"
" Requires the `markdown` command to be on the system path. If you
" do not have the `markdown` command, install one of the following:
"
" http://www.pell.portland.or.us/~orc/Code/discount/
" http://www.freewisdom.org/projects/python-markdown/
"
function!PreviewMarkdown()
" **************************************************************
" Configurable settings
let MARKDOWN_COMMAND = 'markdown'
if has('win32')
" note important extra pair of double-quotes
let BROWSER_COMMAND = 'cmd.exe /c start ""'
else
let BROWSER_COMMAND = 'open'
endif
" End of configurable settings
" **************************************************************
silent update
let output_name = tempname() . '.html'
" Some Markdown implementations, especially the Python one,
" work best with UTF-8. If our buffer is not in UTF-8, convert
" it before running Markdown, then convert it back.
let original_encoding = &fileencoding
let original_bomb = &bomb
if original_encoding != 'utf-8' || original_bomb == 1
set nobomb
set fileencoding=utf-8
silent update
endif
" Write the HTML header. Do a CSS reset, followed by setting up
" some basic styles from YUI, so the output looks nice.
let file_header = ['<html>', '<head>',
\ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">',
\ '<title>Markdown Preview</title>',
\ '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssreset/reset-min.css">',
\ '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssbase/base-min.css">',
\ '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.3.0/build/cssfonts/fonts-min.css">',
\ '<style>body{padding:20px;}div#container{background-color:#F2F2F2;padding:0 20px;margin:0px;border:solid #D0D0D0 1px;}</style>',
\ '</head>', '<body>', '<div id="container">']
call writefile(file_header, output_name)
let md_command = '!' . MARKDOWN_COMMAND . ' "' . expand('%:p') . '" >> "' .
\ output_name . '"'
silent exec md_command
if has('win32')
let footer_name = tempname()
call writefile(['</div></body></html>'], footer_name)
silent exec '!type "' . footer_name . '" >> "' . output_name . '"'
exec delete(footer_name)
else
silent exec '!echo "</div></body></html>" >> "' .
\ output_name . '"'
endif
" If we changed the encoding, change it back.
if original_encoding != 'utf-8' || original_bomb == 1
if original_bomb == 1
set bomb
endif
silent exec 'set fileencoding=' . original_encoding
silent update
endif
silent exec '!' . BROWSER_COMMAND . ' "' . output_name . '"'
exec input('Press ENTER to continue...')
echo
exec delete(output_name)
endfunction
" Map this feature to the key sequence ',p' (comma lowercase-p)
map ,p :call PreviewMarkdown()<CR>
Edit @TommyA ha anche suggerito grip: questo non è un plug-in VIM ma può essere installato con pip install grip. Il vantaggio principale di questo programma è che utilizza l'API di markdown di GitHub, quindi il rendering dovrebbe essere abbastanza vicino a come apparirà il tuo markdown sulle pagine di Github.
Questo programma servirà i tuoi file markdown localhost:6419per impostazione predefinita. Dovresti essere in grado di invocarlo da Vim con:!grip