Rendering html can be implemented by using a text-based web browser which can extract a formatted view of the text from an html file or a web page.
In example:
:!links -dump %
:!elinks -dump %
:!lynx -dump %
:!w3m -dump %
To define your own html preview command, try:
:command! ViewHtml execute ':!links -dump %'
:ViewHtml
Then you can associate this custom command with some key for easier access, by e.g.:
:nnoremap <Leader>H :ViewHtml<CR>
then pressing \H will preview html of the current file.
To preview current file in separate window or to open hyperlinks, you may try to use the following code:
function! ViewHtmlText(url)
if !empty(a:url)
new
setlocal buftype=nofile bufhidden=hide noswapfile
execute 'r !elinks ' . a:url . ' -dump -dump-width ' . winwidth(0)
1d
endif
endfunction
" Save and view text for current html file.
nnoremap <Leader>H :update<Bar>call ViewHtmlText(expand('%:p'))<CR>
" View text for visually selected url.
vnoremap <Leader>h y:call ViewHtmlText(@@)<CR>
" View text for URL from clipboard.
" On Linux, use @* for current selection or @+ for text in clipboard.
nnoremap <Leader>h :call ViewHtmlText(@+)<CR>
Source: vim wikia
Using above code, you can press \H to save and preview the current file. To preview currently selected hyperlink, press \h.
Related:
lynx,links,elinks, orw3m? Vim is a text editor, not a web browser ... you can do this from within Vim even, with:!lynx %– Martin Tournoij Feb 16 '15 at 14:07