Search code examples
vimvi

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).

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.

Therefore, I'd like having a hack to rapidly open vim at the right point just with a paste. Is there any config on vim level or alias I could use?!

Thanks


Solution

  • There are plugins that trap the BufNewFile,BufRead events, parse out the file name and number(s), and redirect to the corresponding file:

    • file-file is the minimalistic original plugin
    • vim-fetch supports multiple ways of specifying the number(s), overloads some mappings (like gf), and even offers a :Fetch command