My home, musings, and wanderings on the world wide web.
Editing markdown in Vim and previewing in Firefox.
Lately, I have taken to maintaining most of my text in Markdown (desperately trying to avoid Emacs’ org-mode) and previewing it while editing in Vim is something that is a nice to have. So I searched a little bit and found this nice little snippet by Ellen Gummesson that I then adapted per my preferences as such:
1234567891011121314151617
" Preview markdown in Firefoxfunction! PreviewMarkdown()let outFile = expand('%:r') . '.html'silent execute '!cd %:p:h'silent execute '!python -m markdown % >' . outFile
" The screen will need to be redrawn. Dunno why! :\silent execute 'redraw!'endfunctionaugroup markdown
au!auBufNewFile,BufRead *.md,*.markdown setlocalfiletype=ghmarkdown
auBufNewFile,BufRead *.md,*.markdown setlocaltextwidth=0autocmdFileType ghmarkdown map <LocalLeader>p \ :call PreviewMarkdown()<CR>augroup END