首次原创,谢谢大家支持
现在很多ajax程序员使用Aptana作为eclipse插件来写js,html等
我刚发现了aptana带的一种很好用的小插件,ecipse monkey。
当我们eclipse装了aptana之后,会在头部菜单栏发现多了Scripts一栏。
刚发现这个插件几个应用。
我发现在写js时候,要插入注释或者注释某些行很麻烦,虽然aptana有Snippets可以插入注释等,
可是觉得扩展性不强。
我们可以用eclipse monkey来做这件事情,很方便的插入比如下面这种
只要按下快捷键alt+s
格式化的注释,
或者这种,快捷键alt+c
比如你修改了某段,你加入这个,以后其他人也知道出于你手。
这些功能是monkey不提供的,是自己定制的,其实很简单,我写了几个简单的js文件,放在
aptana插件路径(这里使用eclipse的link来管理外部的插件)下的eclipse\plugins\com.aptana.ide.scripting_0.2.8.15936\monkey里面加入如下的压缩包selfCommand,然后在上层目录aptana_Home\eclipse\plugins\com.aptana.ide.scripting_0.2.8.15936底下的plugin.xml最后的前面加入
<scriptpath directory="monkey/selfCommand"></scriptpath> <scriptpath directory="monkey/selfCommand"></scriptpath>
,完成注册这个selfCommand包,然后再次打开eclipse,打开顶部的scripts菜单,可以看到我们自己定义的selfCommand。而快捷键可以自己设定(最好不要和其他插件的快捷键冲突);这样我们可以定制出自己想要的js模板,对于经常要重复写的代码可以这样用快捷键加入,当然这个只是这个monkey的一个用法,他还有其他例子用法有待研究。
最后强调一下,如果不想把自定义的命令加入eclipse\plugins\com.aptana.ide.scripting_0.2.8.15936\monkey之中,你也可以临时定制,在你自己的工程中,一般会有一个scripts文件夹,你可以随便加入一个js文件,比如help.js。
然后写入如下格式代码
第一行menu自己写你的命令名字
第二行加入快捷键,这里M3+M代表alt+M
具体是
main方法是一定要提供的
大家可以研究monkey的其他便利之处。