一旦工作,那就要努力的干,聪明的干,快速的干——用省下来的时间干自己喜欢干的事情。!

使用vim粘贴代码时格式变乱,自动缩进,自动加注释解决方案

linux lampnick 2949℃ 0评论

需要粘贴到vim的代码如下:

# 指标 instance 的配置
apiVersion: "config.istio.io/v1alpha2"
kind: metric
metadata:
 name: doublerequestcount
 namespace: istio-system
spec:
 value: "2" # 每个请求计数两次
 dimensions:
 reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
 source: source.workload.name | "unknown"
 destination: destination.workload.name | "unknown"
 message: '"twice the fun!"'
 monitored_resource_type: '"UNSPECIFIED"'
---
# prometheus handler 的配置
apiVersion: "config.istio.io/v1alpha2"
kind: prometheus
metadata:
 name: doublehandler
 namespace: istio-system
spec:
 metrics:
 - name: double_request_count # Prometheus 指标名称
 instance_name: doublerequestcount.metric.istio-system # Mixer Instance 名称(全限定名称)
 kind: COUNTER
 label_names:
 - reporter
 - source
 - destination
 - message
---
# 将指标 Instance 发送给 prometheus handler 的 rule 对象
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
 name: doubleprom
 namespace: istio-system
spec:
 actions:
 - handler: doublehandler.prometheus
 instances:
 - doublerequestcount.metric

按照默认的方式,打开vim,使用insert模式粘贴出现下面的情况

insert_bad

解决方案:

在命令模式下输入:set paste,然后进入insert(paste)模式,再次粘贴,成功解决

insert_ok

转载请注明:MitNick » 使用vim粘贴代码时格式变乱,自动缩进,自动加注释解决方案

喜欢 (4)or分享 (0)
头像
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址