Vim 接受像 `vi path:line:column` 这样的命令

Vim to accept commands like `vi path:line:column`

我经常得到 <path>:<line>:<column> 格式的路径(来自 grep 等文本匹配或代码错误)。

当我双击时,它匹配整个字符串,包括行和列,然后我通常删除列,并将 :line 替换为 +line 以匹配 vi 参数。

因此,我希望有一个破解方法,只需粘贴即可在正确的位置快速打开 vim。我可以使用 vim 级别或别名的任何配置吗?!

谢谢

有插件可以捕获 BufNewFile,BufRead 事件,解析出文件名和编号,并重定向到相应的文件:

  • file-file是极简原创插件
  • vim-fetch 支持多种指定数字的方式,重载一些映射(如 gf),甚至提供 :Fetch 命令

Use the quickfix list instead:

Vim has a startup option -q to read a quickfix file. So we have options (depending on your shell): cmd > results ; vim -q results

Or my favorite: vim -q <(cmd)