Vim Paste Code Format confusion Solution

Source: Internet
Author: User
from:http://blog.csdn.net/commshare/article/details/6215088 Thanks to the cattle people for their articles. Solved me in vim use, A headache. When Vim creates a new file, the sticky code is automatically indented, resulting in a very confusing format. According to the experience of bloggers, in/etc/vim, modify VIMRC, add set pastetoggle=<f9> before pasting code, enter insert mode, press F9, you can turn off auto indent. When you need to write your own code, into the insert mode, the default is automatically indented. =====vim Copy code contains comments when formatting is lost
Each time you copy the code, if the code has//such comments are easy to let the format out of the way, the following settings can be avoided this situation.

Cancel Auto indent when pasting code

Vim in the paste code will be automatically indented, the code to make a mess, and maybe even because of a line of comments caused by the subsequent code is all commented out, I know that a classmate this time will use VI to open the file and paste it up (I was like this before), in fact, need to set up the first

Set paste

Then paste into insert mode, and the code will not be automatically indented. But the code needs to be automatically indented, but also to change back:

Set Nopaste

The most convenient way is to add a sentence in the. VIMRC:

Set pastetoggle=<f9>

Later in insert mode, you can toggle auto indent by pressing the F9 key.

Http://hi.baidu.com/hellosim/blog/item/a7b165151089fae8c3ce798b.html

Vim Paste Code Format confusion Solution

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.