Convert Vim to HTML

Source: Internet
Author: User
Tags strcmp

On G +, we can see the introduction from netizens and find that Vim can highlight the code into HTML documents according to the current syntax. This is a very considerate small function.

For me, this function has at least two functions. First, put the exported HTML document directly in the blog so that the reader can see the code at a Glance. Second, convert the code to HTML format before sending it to the colleague review, to solve the problem that most of the email client code cannot be automatically aligned.

Tohtml is easy to use.

To convert the entire document to HTML, run the following command in command mode:

: Tohtml

If you only need to convert a few lines of code (such as 30 to 42 lines), execute:

: 30,42 tohtml

The following is the result of Code Conversion from my previous blog:

30 ssize_t my_show(struct kobject *kobj, struct attribute *attr, char *buffer)31 {32         struct my_kobj *obj = container_of(kobj, struct my_kobj, kobj);33         ssize_t count = 0;34 35         if (strcmp(attr->name, "name") == 0) {36                 count = sprintf(buffer, "%s\n", kobject_name(kobj));37         } else if (strcmp(attr->name, "val") == 0) {38                 count = sprintf(buffer, "%d\n", obj->val);39         }40 41         return count;42 }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.