Paste Mode: Pasting text (and indenting it) in Vim

Marqué :

Pasting a block of code copied from elsewhere in Vim is a nightmare, unless you know how to do it right. The autoindent (and, possibly, smartindent) features of Vim go crazy when you yank and slap a block of text. How do you do it right, then? This is not a new trick, but something I did not know about for a long time, so I suppose it is reasonable to assume many others who use Vim may not have come across it either. It is called the paste mode. In Vim, you can enable the paste mode by typing :set paste on Vim’s command interface. Once the paste mode is enabled, you can paste the block(s) of code you have yanked from elsewhere, and disable the paste mode through the command :set nopaste as soon as you are done with pasting text. A bit inconvenient, but it is a handy feature to get familiar with if you use Vim a lot to write code.

Voir aussi