我想知道是否有一个程序可以与我想要替换的术语列表一起使用,而不是一个一个地替换。
例子
À=À
â=â
Â=Â
å=å
Å=Å
ã=ã
Ã=Ã
先感谢您
我使用UltraEdit和powergrep atm。
这是我的 umlaut2html-Makro,它做了一些自动文本替换。我想它可以作为灵感;-)
// Lessons learned from Mofi ;-)
UltraEdit.ueReOn();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=false;
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replaceAll=true;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.findReplace.selectText=false;
UltraEdit.activeDocument.findReplace.regExp=false;
UltraEdit.activeDocument.findReplace.replace("ä","ä");
UltraEdit.activeDocument.findReplace.replace("ö","ö");
UltraEdit.activeDocument.findReplace.replace("ü","ü");
UltraEdit.activeDocument.findReplace.replace("Ä","Ä");
UltraEdit.activeDocument.findReplace.replace("Ö","Ö");
UltraEdit.activeDocument.findReplace.replace("Ü","Ü");
UltraEdit.activeDocument.findReplace.replace("ß","ß");
将此保存到您喜欢的任何位置的 .js 文件中(MyDocuments\UE-Scripts
可能是一个不错的选择),然后调用 Script >“Scripts...”和“Add”,导航以选择该 .js 文件。
UltraEdit有 2 个自动重新格式化任务的功能:宏和脚本。
有关差异的简要概述,请参阅 UltraEdit 论坛主题何时使用脚本而不是宏。
UltraEdit 宏可以通过简单地记录您在文件上手动执行一次的替换来创建,或者您直接在“编辑/创建宏”对话框中对其进行编码。
手动创建如下:
ReplaceEntities
。InsertMode
ColumnModeOff
HexOff
然后宏就可以使用了
此外,根据上次执行的宏,可以非常频繁地使用宏 - 再次播放。
除了对话框中已经存在的 3 个标准命令之外,还需要宏代码来替换整个活动文件 HTML 实体,例如:
Top
UltraEditReOn
Find MatchCase "À"
Replace All "À"
Find MatchCase "â"
Replace All "â"
Find MatchCase "Â"
Replace All "Â"
Find MatchCase "å"
Replace All "å"
Find MatchCase "Å"
Replace All "Å"
Find MatchCase "ã"
Replace All "ã"
Find MatchCase "Ã"
Replace All "Ã"
需要使用Macro - Save All将此 UE 宏(不带或带有其他 UE 宏)保存到宏文件中。
为了以后再次使用这个宏(以及存储在同一个宏文件中的其他宏),有必要使用Macro - Load 加载宏文件。
使用宏 - 设置自动加载,可以选择在 UltraEdit 启动时自动加载的宏文件,以便该宏文件中的宏从一开始就可用,而无需显式加载宏文件。
稍后也可以使用Macro - Delete Macro/Modify Properties 更改宏属性。在对宏代码或其属性进行更改后,不要忘记使用宏 - 全部保存以将此更改保存在宏文件中。
UltraEdit 脚本利用 JavaScript 核心引擎。UltraEdit 脚本是一个 ASCII/ANSI 文本文件,其中包含 JavaScript 核心代码和额外的 UltraEdit 相关脚本命令。这意味着 UltraEdit 脚本可以像任何其他文本文件一样直接编写,并且不得在对话框中进行编辑。
与上面的宏完全相同的 UltraEdit 脚本将是:
if (UltraEdit.document.length > 0) // Is any file opened?
{
// Define environment for this script.
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.hexOff();
// Move caret to top of the active file.
UltraEdit.activeDocument.top();
// Define all parameters for several Replace All in entire active file.
UltraEdit.ueReOn();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=false;
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replaceAll=true;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.findReplace.selectText=false;
// This property is only available since UE v14.10.
if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean")
{
UltraEdit.activeDocument.findReplace.searchInColumn=false;
}
UltraEdit.activeDocument.findReplace.replace("À","À");
UltraEdit.activeDocument.findReplace.replace("â","â");
UltraEdit.activeDocument.findReplace.replace("Â","Â");
UltraEdit.activeDocument.findReplace.replace("å","å");
UltraEdit.activeDocument.findReplace.replace("Å","Å");
UltraEdit.activeDocument.findReplace.replace("ã","ã");
UltraEdit.activeDocument.findReplace.replace("Ã","Ã");
}
例如,此类 UltraEdit 脚本应以文件扩展名.js保存ReplaceEntities.js
。
保存 UE 脚本后,可以通过Scripting - Scripts将其添加到脚本列表中,并为脚本添加简短描述并为脚本分配热键/和弦,以便通过按键快速执行。
然后脚本就可以使用了
如果 UE 脚本是活动文件并且它被编写为不在活动文档上运行,则该脚本也可以使用Scripting - Run Active Script执行。但是大多数像上面这样的脚本都是为了在活动文件上运行而编写的,因此需要将脚本文件添加到脚本列表中才能执行。
JavaScript 的核心对象和函数在 UltraEdit 中的任何地方都没有记录,尽管它们也可以在 UltraEdit 脚本中使用。核心功能的文档可以在Mozilla 开发者网站上找到。
UltraEdit 的附加脚本命令记录在 UE 的帮助页面中,标题为Scripting commands。另外还有View - Views/Lists - Tag List包含标签组UE/UES Script Commands和UE/UES Macro Commands,用于在插入符号当前位置的活动文件中快速添加 UE 的脚本或宏命令。