Defining my own command
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:开发者_StackOverflow
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?
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.
精彩评论