Using Vim to generate HTML output of code


This is an interesting bit that I learnt about from an email in a mailing list by James Pryor.

To generate html output for code within a shell script you can use:

vim myscript.sh '+syntax on' '+ set nu' '+set background=light' +TOhtml '+w myscript.html' '+qall!'
If you don’t want numbers and need a dark background you can use:
vim myscript.sh '+syntax on' '+ set nonu' '+set background=dark' +TOhtml '+w myscript.html' '+qall!'
Advertisements

About Sayak Sarkar

Web Ninja, Open Source Evangelist, Mozillian, Geek, Currently working as a Web Developer at Red Hat. In the past I've worked at Mozilla Foundation, Software Development & Research Cell at SICSR. Originally from Kolkata, West Bengal. Open Source Contributor with a special interest in Web Development. Follower of all updates related to Free and Open Source Software.

Posted on April 28, 2016, in How-to Guides, Technology, Vim and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: