Vim Paste Cancel Auto Indent

Source: Internet
Author: User

Vim Copy and Paste Quest

Vim is one of the best text editors to use Vim to document, writing code is really a pleasant thing. Whenever you learn a new function of vim, it will greatly improve the efficiency. The use of vim for decades has not yet fully mastered the functionality of Vim, which also illustrates the power of vim. And this is not a good thing, as long as some study, there are improvements.

The recent use of vim to write a blog, found in vim after pasting Python code, indentation is completely chaotic. Careful study of the following, the original is automatically indented for the sake of, so do the following settings:

Auto indent and Smart indent are canceled, so the paste will not go wrong. But in some vim does not work, or typesetting disorder.

Later found a better use of the settings:

After entering paste mode, you can paste the content in insert mode without any distortion. This is really gray often use, can't help but look at the help, found that it did so many things:

    • TextWidth set to 0
    • Wrapmargin set to 0
    • Set Noai
    • Set Nosi
    • Softtabstop set to 0
    • Revins Reset
    • Ruler Reset
    • Showmatch Reset
    • Formatoptions using null values

The following option values are not changed, but are disabled:

    • Lisp
    • indentexpr
    • Cindent

No wonder before only set Noai and Nosi not, originally with so many factors related!

But this is still more troublesome, each time to paste, the first set paste, and then paste, and then set Nopaste. Is there any more convenient? You may have thought of it, using a keyboard mapping Yes, yes. We can set this::

So before pasting press F10 key to start paste mode, paste and press F11 cancel paste mode. In fact, paste has an option to toggle the paste switch, which is pastetoggle. It allows you to bind shortcut keys to activate/deactivate paste mode. Like what::

This reduces the use of a shortcut key, which is more convenient.

Transferred from: https://www.cnblogs.com/end/archive/2012/06/01/2531147.html

Vim Paste Cancel Auto Indent

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.