2

Environment: Linux

I apologize in advance if this question already exists somewhere and has a proper answer. It is just so difficult for me to search because the keywords are all so generic.

Put simply, I want to know a way to do what one might expect this to do:

:edit !which command

This gives the following error:

E172: Only one file name allowed

because the parameters to edit are not being evaluated.

I have tried various incantations with execute, eval, and even norm but I can't make the magic work.

1

1 Answer 1

2

I think this is what you want to do. I just tested it and it worked for me.

:edit `which command`

Wrap the argument to :edit in backticks rather than preceding it with a "!".

3
  • Thanks but that is actually giving me this different error: ``` :e `which my_script.py` E79: Cannot expand wildcards "which my_script.py" [New File] ``` (Sorry, can't figure out how to do block of code in comments)
    – Josh Thies
    Jun 19, 2022 at 16:14
  • please update your answer and remove the backslash and it will be correct: :edit `which command` You have to type: <backtick>:edit <backslash><backtick>which command<backslash><backtick><backtick> in order for it to display in the answer correctly.
    – Josh Thies
    Jun 19, 2022 at 16:25
  • @JoshThies Oh, dear. I hadn't meant to type that backslash. I'm sorry.
    – MDeBusk
    Jun 19, 2022 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.