Wednesday, January 16, 2013

Vim Using elinks with netrw


Tip: Using elinks with netrw


The Vim Netrw plugin allows one to view the contents of an http hyperlink via CTRL-W_CTRL-F. Netrw checks the user's system (in this order) for curl, wget, and fetch. Text browsers such as elinks and links are better alternatives to HTTP clients like curl because they have a -dump option which strips out the HTML tags and formats tables for improved ASCII viewing. Getting these text-based web browsers working with Netrw requires a simple wrapper script to format the arguments in the order that Netrw provides them:

$ agent tempfile url

Here is a sample wrapper script for elinks (in a file named elinks-for-vim).

#!/bin/sh
tempfile=`echo $* | awk '{print $1}'`
url=`echo $* | awk '{print $2}'`
elinks -dump $url > $tempfile
Then, add this line to your vimrc:

let g:netrw_http_cmd = "elinks-for-vim"

Reference:

created July 25, 2008 · complexity basic · author Emallove · version 7.0