一般的vim都默认设置为set nopaste。在粘贴前设置:
set paste使得vim进入粘贴模式,则粘贴过来的内容能够保持原来的格式。
设置前的粘贴效果:
You can format/indent an entire file using the gg=G command, where
gg - Goto the beginning of the file
= - apply indentation
G - till end of file
For more information, read
:help gg
:help =
:help G
:help ''formatprg''
:help C-indenting
设置set paste后的效果:
You can format/indent an entire file using the gg=G command, where
gg - Goto the beginning of the file
= - apply indentation
G - till end of file
For more information, read
:help gg
:help =
:help G
:help ''formatprg''
:help C-indenting
但是在粘贴插入模式下代码是不会自动按格式缩进的,需要使用nopaste设置回来
:set nopaste
---------------------
作者:victoryckl
来源:CSDN
原文:https://blog.csdn.net/victoryckl/article/details/8168245
版权声明:本文为博主原创文章,转载请附上博文链接!