解决vim粘贴内容缩进错乱问题

平时经常用vim编辑服务器端一些配置文件和脚本,当复制粘贴内容时,会因为自动缩进把代码缩进搞乱了。

解决办法:进入粘贴模式粘贴内容。

1
:set paste

我们不能直接通过修改配置来适应粘贴内容,因为粘贴模式下配置变化:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
textwidth = 0
wrapmargin = 0
set noai
set nosi
softtabstop = 0
revins 重置
ruler 重置
showmatch 重置
formatoptions 使用空值

# 下面的选项值不变,但却被禁用:
lisp
indentexpr
cindent
# vim
You forgot to set the qrcode for Alipay. Please set it in _config.yml.
You forgot to set the qrcode for Wechat. Please set it in _config.yml.
You forgot to set the business and currency_code for Paypal. Please set it in _config.yml.
You forgot to set the url Patreon. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×