问题
I'm trying to define my own command in MacVim to turn a c statement or range of statements into comments. So I put this in my vimrc:
command -range Com :<line1>,<line2>s?^.*$?/*&*/?
It works fine if I just enter :Com to comment the current line. But if I enter something like :Com 3 5 in order to turn lines 3 thru 5 into comments I always get this error message:
E488: Trailing characters
Can anyone help?
回答1:
You need to provide the range before the command, like that:
:3,5Com
Anyway, I suggest you to check the NERD_commenter plugin. It's great for commenting source code.
来源:https://stackoverflow.com/questions/6180747/defining-my-own-command