1

I have read map.txt in vim doc and tried to create my Ex command. But the doc is quite hard to understand.

I wanna write a command to call 2 command is PlugInstall and CocInstall.

command! MyCommand :PlugInstall<Cr>:CocInstall<Cr>

But it didn't work. Any different document to help me write user-defined command easier? Thank you.

1 Answer 1

5

It looks like you are trying to use :command like :map to map a series of keys. But they are different. In a user-defined command, you don't need : to enter into command-line mode and you don't need <CR> to execute the command and you need to use | to separate the commands. You can try using the following:

command! MyCommand PlugInstall | CocInstall

You can refer to :help 40.2 in the user-manual for information about creating new commands.

1
  • Can you give me another reference for this ( videos, maybe)? I've tried to understand official doc but it's quite hard for newbie like me.
    – Pham Hung
    Commented Jan 3, 2022 at 4:29

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.