Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: support for file addresses #4707

Open
myitcv opened this issue Jul 20, 2019 · 11 comments
Open

proposal: support for file addresses #4707

myitcv opened this issue Jul 20, 2019 · 11 comments

Comments

@myitcv
Copy link

myitcv commented Jul 20, 2019

Is your feature request related something that is currently hard to do? Please describe.

The feature I am looking for can currently be provided by plugins, for example https://github.com/plan9-for-vimspace/plan9-for-vimspace/.

I'm raising this proposal because I think this is something that could usefully be provided natively.

Describe the solution you'd like

https://github.com/plan9-for-vimspace/plan9-for-vimspace/ and others support the concept of opening files at specific addresses. e.g. from the command line:

$ vim path/to/file:$line:$colbyteoffset

would open path/to/file and move the cursor to line $line and col byte offset $colbyteoffset.

This form also works within vim, via :e, :sp etc.

I believe this format of address is relatively standard (and has its origins in sam)

Here is a rough list of plugins that provide this functionality:

Describe alternatives you've considered

An alternative is clearly to implement this in a plugin. But this requires people to install a plugin for something that is relatively "core".

Additional context

n/a

@chrisbra
Copy link
Member

There have been some discussions about it in the past. I suppose a custom core plugin could solve it.

Note, although unlikely, this wish is quite controversial and might prevent actually editing a file that is actually called with a colon. So I believe a custom plugin is better than changing the semantics.

There is at least vim-fetch, not sure how well it works or what other alternatives exists. I remember having seen a similar plugin 10 years ago, but can't remember.

@myitcv
Copy link
Author

myitcv commented Jul 22, 2019

this wish is quite controversial and might prevent actually editing a file that is actually called with a colon. So I believe a custom plugin is better than changing the semantics.

Agreed, we don't want to break backwards compatibility here. A custom core plugin sounds like a good compromise.

There is at least vim-fetch, not sure how well it works or what other alternatives exists

Thanks. I've edited my comment above to add a list of plugins which we could use as a reference point if this is something we want to make core.

@marcotrosi
Copy link

I don't know if this is helpful but it could be solved with a little shell script.

You could write a Vim wrapper, for example you can name it simply "v".

It would split the parameter you showed in your example ...

v path/to/file:$line:$colbyteoffset

and call vim for you with ...

vim path/to/file -c 'normal $lineG$colbyteoffset|'

e.g.

v foobar.txt:39:12
vim foobar.txt -c 'normal 39G12|'

@andymass
Copy link

andymass commented Aug 3, 2019

There is also https://github.com/bogado/file-line and https://github.com/lervag/file-line .

The only problem with a wrapper script is :e file:10 wouldn't work.

@marcotrosi
Copy link

true, there is only :e file +10

@lilydjwg
Copy link
Contributor

lilydjwg commented Aug 5, 2019

There is also my search-and-view vv tool that calls Vim via +clientserver.

@myitcv
Copy link
Author

myitcv commented Aug 5, 2019

@marcotrosi a key part of this proposal is that it should be easy to copy-paste file addresses from output of commands, e.g. compiler output, grep etc. Hence the :e approach also needs to work.

@marcotrosi
Copy link

yes I know. And I agree that some things should work out of the box even if they could be easily realized with small command or function. Like here you could write a command named :E and implement what you need, but as I said some things should work by default. E.g. for consistency reasons.
Of course someone could also argue that if you use quickfix lists for compiler and grep outputs then you have already that feature, so Bram/one could say "why don't you use it and why do you copy manually?". It's at least a legit question.

@myitcv
Copy link
Author

myitcv commented Aug 5, 2019

The proposal here is not for this to work out of the box. Per @chrisbra's comment, because of backwards compatibility concerns we need this to be something that is turned on by enabling a plugin or some such.

I'm not quite sure I follow your point about trying to eliminate any copy paste by saying people should use quickfix lists. This proposal includes that this should also work from the command line. Also, there are plenty of times when the output I am working with is not in Vim.

Are there specific reasons you think this proposal, as a plugin, would not work/be a bad idea?

@marcotrosi
Copy link

The proposal here is not for this to work out of the box. Per @chrisbra's comment, because of backwards compatibility concerns we need this to be something that is turned on by enabling a plugin or some such.

I'm not quite sure I follow your point about trying to eliminate any copy paste by saying people should use quickfix lists. This proposal includes that this should also work from the command line. Also, there are plenty of times when the output I am working with is not in Vim.

Are there specific reasons you think this proposal, as a plugin, would not work/be a bad idea?

Oh I'm sorry if I made you think that I'm pro or against any solution. I did not judge. I only wanted to discuss pros and cons of possible solutions. Just collecting thoughts and ideas and listing pros and cons. Just some happy chatting with you guys. Nothing more. Sorry if I transported a different message.

@cecamp
Copy link
Collaborator

cecamp commented Aug 5, 2019

Look into using an autocmd (probably BufReadCmd) in a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants