Defining my own command

*爱你&永不变心* 提交于 2019-12-20 02:54:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!