1

I want to run an external command by typing :runMyCommand (just run a shellcommand). I thought I'd put the shell command execution into a function, so I can call it with :call runMyCommand, but I want to get rid of the :call.

Is this possible and if yes, how? (I guess something like this was already asked, but in my opinion this issue is really hard to search for)

1 Answer 1

4

:h :command will put you on the right track.

It can be as simple as

command! RunMyCommand call RunMyCommand()

Or much more complex if you want to support arguments, range...

2
  • This is exactly what I was searching for (but not knowing how this is called in vim) :+1:
    – atticus
    Commented Jun 12, 2020 at 15:05
  • @D.BenKnoble You're right. I've copy-pasted OP's code and I forgot along the way about command restrictions. I fix my answer. Commented Jun 12, 2020 at 16:59

Your Answer

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

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