您的位置:首页 > 编程语言

[vim]粘贴到vim的代码,怎样避免向右不断缩进,保持原来的格式?

2012-11-10 00:02 393 查看
一般的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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: