`
heimuad
  • 浏览: 293330 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Aptana使用之ecilpse monkey技巧

阅读更多

首次原创,谢谢大家支持

现在很多ajax程序员使用Aptana作为eclipse插件来写js,html等

我刚发现了aptana带的一种很好用的小插件,ecipse monkey。

当我们eclipse装了aptana之后,会在头部菜单栏发现多了Scripts一栏。

刚发现这个插件几个应用。

我发现在写js时候,要插入注释或者注释某些行很麻烦,虽然aptana有Snippets可以插入注释等,

可是觉得扩展性不强。

我们可以用eclipse monkey来做这件事情,很方便的插入比如下面这种
只要按下快捷键alt+s

格式化的注释,

或者这种,快捷键alt+c

 

  1. // @%change By Liuhy%@    el.eventRouter=this;   
  2. // @%change By Liuhy%@    el[eventType]=jsEvent.EventRouter.callback;  
js 代码

比如你修改了某段,你加入这个,以后其他人也知道出于你手。

这些功能是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>

  1. <scriptpath directory="monkey/selfCommand"/>  

,完成注册这个selfCommand包,然后再次打开eclipse,打开顶部的scripts菜单,可以看到我们自己定义的selfCommand。而快捷键可以自己设定(最好不要和其他插件的快捷键冲突);这样我们可以定制出自己想要的js模板,对于经常要重复写的代码可以这样用快捷键加入,当然这个只是这个monkey的一个用法,他还有其他例子用法有待研究。

最后强调一下,如果不想把自定义的命令加入eclipse\plugins\com.aptana.ide.scripting_0.2.8.15936\monkey之中,你也可以临时定制,在你自己的工程中,一般会有一个scripts文件夹,你可以随便加入一个js文件,比如help.js。

然后写入如下格式代码

js 代码
  1. /*  
  2.  * Menu: test with Liuhy     
  3.  * Key: M3+M  
  4.  * Kudos: Michelle Petersen  
  5.  * License: EPL 1.0  
  6.  * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript  
  7.  * OnLoad: main()  
  8.  */  
  9. //change by lihy   
  10.   function main()   
  11.   {   
  12.  //自己定义,调用monkey提供的接口。     
  13.   }  

第一行menu自己写你的命令名字

第二行加入快捷键,这里M3+M代表alt+M

具体是

  • M1 (Command or Ctrl)
  • M2 (Shift)
  • M3 (Option or Alt)
  • M4 (Ctrl on Mac)

    main方法是一定要提供的
     

    大家可以研究monkey的其他便利之处。

    • selfCommand.rar (4 KB)
    • 描述: 解压放到aptana_Home\eclipse\plugins\com.aptana.ide.scripting_0.2.8.15936\monkey
    • 下载次数: 174
    • 大小: 18.2 KB
    分享到:
    评论
    1 楼 sp42 2007-08-27  
    团队开发时正适合~~赞赞

    相关推荐

    Global site tag (gtag.js) - Google Analytics