ultraEdit 注释插件
不要跟我说vim,不要跟我说linux,我也是被逼的
直接上代码:(ue还不内部脚本还不支持activeX对象,所以好多功能都没法实现...所以我一直都用vim )
//file: auth.js //desc: pig //author: ifree //last modified date: Monday, December 19, 2010 21:54:55 ( function(ue){ var currentDoc=ue.activeDocument; var debug=ue.outputWindow; function getFileName(){ var path=currentDoc.path; return path.substring(path.lastIndexOf("\\")+1,path.length); } function getDate(){ return new Date().toLocaleString(); } function desc(obj){ for(var i in obj){ debug.write("{"+i+":"+obj[i]+"}\r\n"); } } //render whole or single template function templateHandler(){ var template=[]; template["file"]="//file: {getFileName()}"; template["desc"]="//desc: {desc}"; template["author"]="//author: {author}"; template["last modified date"]="//last modified date: {getDate()}"; var reg=/{(.+)}/; function renderSelf(key,value){ if(!key)return; var str=template[key]; if(!str)return; reg.exec(str); if(RegExp.$1.indexOf('(')>=0){ str=str.replace(reg,eval(RegExp.$1)); }else str=str.replace(reg,value); return str; } return { render:function(obj){ var ret=""; for(var i in template){ ret+=renderSelf(i,obj[i]?obj[i]:'')+"\r\n"; } return ret; }, renderSingle:function(k,v){ return renderSelf(k,v); } } } //get output return function(cfg){ currentDoc.write("{"+"cursor"+"}"); var reg=/\/\/([\w\s]+):(\s?.+)/; currentDoc.gotoLine(5); currentDoc.selectToTop(); var texts=currentDoc.selection.split("\r\n"); //detect if comment has added if(reg.test(texts[0])){ for(var i=0,il=texts.length;i<il;i++){ if(reg.test(texts[i])){ texts[i]=templateHandler().renderSingle(RegExp.$1.trim(),RegExp.$2.trim()); } } currentDoc.deleteText(); currentDoc.write(texts.join('\r\n')); }else{ currentDoc.selectAll(); currentDoc.write(templateHandler().render(cfg)+currentDoc.selection); } //set cursor to orign posi currentDoc.top(); currentDoc.findReplace.find("{"+"cursor"+"}"); currentDoc.deleteText(); } } )(UltraEdit)({author:"ifree"});