gpt4 book ai didi

vim - 在 Vim 中调整/对齐错误格式输出

转载 作者:行者123 更新时间:2023-12-05 01:20:46 25 4
gpt4 key购买 nike

我使用 Vim/gVim 在 javascript (node) 中进行编程。我在我的文件类型插件中将 jslint 连接为 makeprg。这是错误格式:

efm=%-P%f,
\%A%>%\\s%\\?#%*\\d\ %m,%Z%.%#Line\ %l\\,\ Pos\ %c,
\%-G%f\ is\ OK.,%-Q

这是 jslint 的输出:

routes/pcr.js
#1 'db' was used before it was defined.
db.collection('pcrs', function (err, collection) { // Line 11, Pos 5
#2 'db' was used before it was defined.
db.collection('pcrs', function (err, collection) { // Line 23, Pos 5
#3 'BSON' was used before it was defined.
collection.findOne({'_id': new BSON.ObjectID(id)}, function (err, item) { // Line 24, Pos 40

这是 quickfix 窗口的输出:

routes/pcr.js|11 col 5| 'db' was used before it was defined.
routes/pcr.js|23 col 5| 'db' was used before it was defined.
routes/pcr.js|24 col 40| 'BSON' was used before it was defined.

在列号之后,我想留下 2 位数字(我希望文件中的错误不超过 99 个!),这样它看起来像:

routes/pcr.js|11 col  5| 'db' was used before it was defined.
routes/pcr.js|23 col 5| 'db' was used before it was defined.
routes/pcr.js|24 col 40| 'BSON' was used before it was defined.

我想这也会影响行号 0-9。是否可以有条件地填充输出?

最佳答案

合理的数字当然很好,但我认为这需要 Vim 的源代码补丁。

quickfix 窗口中的信息来自 Vim 的内部数据结构(格式见 :help getqflist()),Vim 决定如何将其可视化。

关于vim - 在 Vim 中调整/对齐错误格式输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16352306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com