VIM: Resolves a number of indentation and whitespace issues at the beginning of the Vi/vim when pasting

Source: Internet
Author: User

Resolves an issue where there are many indents and spaces at the beginning of the Vi/vim when pasting http://www.jbxue.com/LINUXjishu/12232.html

Because the original text will be sent to the server in the same style as the string in SecureCRT.
So the vim on the server is set to Autoindent, and in the I mode, it will indent the strings that are transmitted by SECURECRT.
If there are spaces or tabs in the copied text that indicate indentation, they are also indented as strings.

Workaround:
1, input before copy: Set paste (so that Vim does not start auto indent, but only copy paste)
2, after the copy is complete, enter: Set Nopaste (Close paste)

Attached, paste related knowledge.
' Paste ' Boolean (default off)
Global
{Vi does not have this function}
Switch Vim to paste mode. Can be used to cut or copy text from a window and paste it into Vim. The use of it avoids some unintended effects.
Setting this option can be used for vim running on the terminal, where vim cannot distinguish between the input and the pasted text. In the GUI, Vim knows what comes from the paste, and doesn't do anything wrong even if it doesn't open ' paste '.
This is true for Vim, which can handle mouse clicks on its own.
Resets this option when the GUI is started. So if you place it in the. VIMRC, you can make it work in the terminal, but not in the GUI.
There are side effects of placing ' paste ' in the GUI: for example, Paste toolbar button does not work in insert mode because it uses mappings.
When the ' paste ' option is turned on (including when it is already open):

-Mask the mapping of Insert mode and command line mode
-Shielding Abbreviations
-' textwidth ' set to 0
-' Wrapmargin ' set to 0
-' autoindent ' is reset
-' smartindent ' is reset
-' softtabstop ' set to 0
-' Revins ' is reset
-' ruler ' is reset
-' Showmatch ' is reset
-' formatoptions ' is used as if it were empty

The following options keep the original values, but have no actual effect:

-' Lisp '
-' indentexpr '
-' cindent '

Note: If you start editing other files when you open the ' paste ' option, Mode lines or automatic commands may change these settings again, causing trouble when pasting text.
You may need to reset the ' paste ' option again.
When the ' paste ' option is reset, the options mentioned above are restored to the last ' paste ' setting when it is turned off.
Reset ' paste ' before resetting ' paste ' has no effect.
Because the ' paste ' cannot be used for mapping, the ' pastetoggle ' option can be used to specify a hotkey to toggle the ' paste ' option.

VIM: Resolves a number of indentation and whitespace issues at the beginning of the Vi/vim when pasting

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.