Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Last active October 29, 2024 22:30
Show Gist options
  • Save Konfekt/c2066abc31b41430417310bd6e6d795e to your computer and use it in GitHub Desktop.
Save Konfekt/c2066abc31b41430417310bd6e6d795e to your computer and use it in GitHub Desktop.
A dead-simple markdown previewer in Vim thanks to KDE's document viewer Okular

KDE's document viewer Okular renders markdown as HTML (and reloads it automatically on changes.) Thus, simply open the markdown file currently edited in Vim in Okular to be all set!

To start an GUI application from Vim, without freezing, hit-<enter> prompts or scrambling screen lines, one can add a command such as

if has('unix')
  command! -complete=shellcmd -nargs=1 -bang Silent execute ':silent !' . (<bang>0 ? 'nohup ' . <q-args> . '</dev/null >/dev/null 2>&1 &' : <q-args>) | execute ':redraw!'
elseif has('win32')
  command! -complete=shellcmd -nargs=1 -bang Silent execute ':silent !start ' . (<bang>0 ? '/b ' : '') . <q-args> | execute ':redraw!'
endif
command! OK Silent! okular %:S

to call okular by

:OK
@Konfekt
Copy link
Author

Konfekt commented Oct 29, 2024

With the most recent Vim, command! OK Launch okular %:S suffices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment