高级查找&替换/文本扩展/宏

时间:2010-10-11 11:29:34

标签: macros komodo komodoedit

希望对某人来说很快。我正在开发一个项目,需要在400个左右的位置写一个特定的链接。每个链接都是相同的,除了它的城镇名称,例如:

<li><a href="/contact-details.html?location=Andover">Andover</a></li>

我目前正在使用Komodo Edit来编写我的项目,我安装了Zen Coding并且对内置Snippets功能有了不错的了解。

我知道使用Snippets,我可以在密钥绑定中创建Andover这个单词上面的链接,但据我所知,一次只能有一行。

我也知道我可以使用Zen Coding进入以下阶段:

<li><a href="/contact-details.html?location=">Andover</a></li>

但是使用带缩写和

的换行符没有链接中的位置名称
li*>a[href=/contact-details.html?location=]

显然这两个仍然留下了很多的工作要做,而且我敢肯定,这可能与科莫多宏,但我不知道有足够的了解他们这样做。

有谁知道的方式在科莫多,或使用禅编码,或任何网站或应用程序,可以做这样的更高级一些的查找/替换/文本扩展?我已经看到了一些确实可以找到和替换的应用程序,但它们都基于多个文件,这对我需要的东西来说有点多。

理想情况下,我可以编写像

这样的内容
<li><a href="/contact-details.html?location=[%contentOfCurrentLine]">[%contentOfCurrentLine]</a></li>

并一次性将其复制到所有400个地点。

2 个答案:

答案 0 :(得分:0)

使用名为“ListLink”的代码片段:

<li><a href="/contact-details.html?location=[[%W]]">[[%W]]</a></li>

使用scimozprojects API创建一个宏来移动光标并在循环中调用代码段:

komodo.assertMacroVersion(2);
if (komodo.view && komodo.view.scintilla) { komodo.view.scintilla.focus(); }

var i = 1;
var len = ko.views.manager.currentView.scimoz.lineCount; /* Count lines */
_part = ko.projects.findPart('snippet', 'ListLink', '*'); /* Find Snippet*/
ko.views.manager.currentView.scimoz.documentStart(); /* goto first line */

while (i <= len)
  {
  if (!_part) {alert("Couldn't find a snippet called 'ListLink' when executing macro."); return;}
  ko.projects.invokePart(_part); /* invoke Snippet */
  ko.views.manager.currentView.scimoz.lineDown(); /* goto next line */
  i++;
  }

答案 1 :(得分:0)

您可以在 Komode 中执行此操作。

  1. 转到&#34; 修改&#34; (在顶部菜单中),&#34; 查找&#34;。
  2. 将打开一个窗口,检查chackbox&#34; 替换&#34; (或你需要的其他人)
  3. 填写文字字段&#34; 找到&#34;和&#34; 替换为&#34;,点击&#34; 全部替换&#34;
  4. 就这么做!