简体   繁体   English

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

[英]Vim to accept commands like `vi path:line:column`

It's often that I get paths in the format <path>:<line>:<column> (from text matches such as grep or errors on code).我经常以<path>:<line>:<column>格式获取路径(来自文本匹配,例如grep或代码错误)。

When I double click, it matches the whole string, including line and column, then I usually remove the column, and replace :line with +line to match vi parameter.当我双击时,它匹配整个字符串,包括行和列,然后我通常删除列,并将:line替换为+line以匹配vi参数。

Therefore, I'd like having a hack to rapidly open vim at the right point just with a paste.因此,我想有一个 hack,只需使用粘贴即可在正确的点快速打开 vim。 Is there any config on vim level or alias I could use?!我可以使用vim级别或别名的任何配置吗?!

Thanks谢谢

There are plugins that trap the BufNewFile,BufRead events, parse out the file name and number(s), and redirect to the corresponding file:有一些插件可以捕获BufNewFile,BufRead事件,解析出文件名和编号,并重定向到相应的文件:

  • file-file is the minimalistic original plugin file-file是极简的原始插件
  • vim-fetch supports multiple ways of specifying the number(s), overloads some mappings (like gf ), and even offers a :Fetch command vim-fetch支持多种指定数字的方式,重载一些映射(如gf ),甚至提供:Fetch命令

Use the quickfix list instead : 改用快速修复列表

Vim has a startup option -q to read a quickfix file. Vim 有一个启动选项-q来读取 quickfix 文件。 So we have options (depending on your shell): cmd > results ; vim -q results所以我们有选项(取决于你的外壳): cmd > results ; vim -q results cmd > results ; vim -q results

Or my favorite: vim -q <(cmd)或者我最喜欢的: vim -q <(cmd)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM