定义我自己的命令 [英] Defining my own command

查看:55
本文介绍了定义我自己的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在MacVim中定义自己的命令,以将c语句或语句范围转换为注释.所以我把它放在了我的vimrc中:

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?^.*$?/*&*/?

如果我只输入:Com注释当前行,它就可以正常工作.但是,如果我输入类似:Com 3 5的内容,以便将第3行到第5行变成注释,我总是会收到此错误消息:

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

任何人都可以帮忙吗?

推荐答案

您需要在命令 之前提供范围,例如:

You need to provide the range before the command, like that:

:3,5Com

无论如何,我建议您检查 NERD_commenter 插件.注释源代码非常有用.

Anyway, I suggest you to check the NERD_commenter plugin. It's great for commenting source code.

这篇关于定义我自己的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆