Utilize shell scripts,linux commands, open source tools,java, to Maximize the Power of Linux.
Focused on working with linux and shell, search engine technology including Chinese segmenter
Any questions please contact me at gmail: david.ullua

1/15/2007

vim与gvim 转换highlight的文本到html网页

今天发现用gvim居然可以把vim中着色显示的文本文件(c, php, sh, java, ...)转换成html,
且保留显示的格式和颜色,不必再为发布源代码到blog上显示格式混乱的问题了。

在gvim中点syntax => convert to html, 这样会产生一个后缀名加上html的文件,
然后保存即可(:w ).如果要对.html文件或者源文件作适当的编辑,
可以用Ctrl+ww 可以切换源文件与产生的html文件的窗口。

google 了一下"vim convert to html", 原来vim中也可以使用

:runtime! syntax/2html.vim 命令来保存按语法高亮显示的文本到html文件。

参考: http://vimdoc.sourceforge.net/vimfaq.html

24.14. How do I convert a source file (.c, .h, etc) with the Vim syntax
highlighting into a HTML file?

You can use the 2html.vim script to convert a source file into a HTML file

with the Vim syntax highlighting. Use the following command:
:runtime! syntax/2html.vim

For more information, read

:help convert-to-HTML

No comments:

About Me

I am a senior developer and a team leader with 3 years development experience in Suzhou, China, focus on mobile web search, linux, Java and machine learning in NLP (natural language processing). My goal is to improve people's life with computer technology.