Multi-line annotation methods in the Vim compiler (especially for Python code comments)

Source: Internet
Author: User

------------------------------------------------------Multi-line annotations in the VIM compiler--------------------------------------------------------

When writing a Python program under the VIM command, it is sometimes difficult to make multiple lines of comments. Because Python does not use/*xxxx*/as a multi-line comment in the C language, it can only be annotated with # for each line, and if there are hundreds of lines, it has to be commented out. In addition to an honest line of comments, here are a few more ways to share:

The first kind: Use the comment as a string and comment it out with ' xxx ', but it is not recommended.

The second kind: Use the function to put the content to be annotated in it, do not call this function, then these to comment the content is useless, this is better than the first.

The Third kind: This is I more recommend, also today colleague teaches me, share to everybody.

There are a few small steps:

Ctrl + V; The view mode in Vim, select the content to be commented on

SHIFT + I; Insert character

SHIFT + #; Insert # in front of the line to be commented (shown in the first line)

ESC, at least 2 times, will have all the selected rows preceded by the #

The third method is not only useful for Python code multiline annotations, but also useful for multi-line annotations of programs in other languages.


------------------------------------------------------------Shell Multi-command-line operation------------------------------------------------------

For example, to restart all openstack-nova-* services, then if one to start, it is too much trouble, if you write a script can be started. But can be started directly with the command (also see colleague operation)

For item in ' ls | grep ' openstack-nova-* ';d o service $item restart; Done


There's a backup command: CP Test.py{,.bak}

Multi-line annotation methods in the Vim compiler (especially for Python code comments)

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.