Solve the problem of code format disorder or alignment copied from VIM

Source: Internet
Author: User
Solve the problem that the code format copied from VIM is disordered or alignment. This article is suitable for the bird who uses VIM. it is not suitable for the old bird. One problem is that as long as the code is copied from VIM, whether put on CSDN or GITHUB, it will become very ugly. In VIM, you thought it was aligned... solve the problem that the code format copied from VIM is disordered or alignment. This article is suitable for the bird who uses VIM. it is not suitable for the old bird. One problem is that as long as the code is copied from VIM, whether put on CSDN or GITHUB, it will become very ugly. In VIM, you think the alignment is correct. actually, there is no alignment. Let's talk about the CSDN tab. by default, it is the length of 8 spaces, which is very large. even if all indentation is correct, the width of the code will be greatly increased. So I want to avoid using tab in the code (or when using tab, the actual input is space). This can be done in your. add "set expandtab" to the vimrc file, and set tabstop, softtabstop and shiftwidth to the same (after setting expandtab, their values correspond: the number of spaces entered when you press the tab. (for details, refer to the link below ). At this time, whether you enter a tab in the program or type "o" in normal mode, you will achieve the desired effect, and then copy the code to CSDN, github, and other places, let's see if the results have been met. By the way ...... I didn't open cindent, autoindent, and smartindent.
 
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.