搜索并替换为术语列表? [英] Search and replace with term list?

查看:55
本文介绍了搜索并替换为术语列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一个程序可以使用我想要替换的术语列表而不是一个一个.

I wonder if there is a program that I can use with a list of terms I want to replace instead of take one by one.

示例

À=À
â=â
Â=Â
å=å
Å=Å
ã=ã
Ã=Ã

提前致谢

我使用 UltraEditpowergrep atm.

推荐答案

UltraEdit 有 2 个用于自动重新格式化任务的功能:脚本.

UltraEdit has 2 features for automating reformatting tasks: macros and scripts.

请参阅 UltraEdit 论坛主题 何时使用脚本而不是宏 简要概述差异.

See UltraEdit forum topic When to use Scripts over Macros for a brief overview of the differences.

UltraEdit 宏可以通过简单地记录您对文件手动执行的替换操作或直接在编辑/创建宏对话框中进行编码来创建.

An UltraEdit macro can be created by simply recording the replaces you manually do once on a file or you code them directly in Edit/Create Macro dialog.

手动创建如下:

  1. 在菜单项编辑宏上的菜单中单击UltraEdit.
  2. 点击按钮新建宏.
  3. 输入为宏名称,例如ReplaceEntities.
  4. 取消选中宏属性显示此宏的取消对话框.
  5. 勾选宏属性如果未找到搜索字符串则继续.
  6. 如果将来需要按键快速执行宏,请分配热键或和弦以快速执行按键.
  7. 点击按钮确定.
  8. 回到编辑/创建宏,现在使用宏命令在编辑字段中选择了 3 行的新宏:
    插入模式
    ColumnModeOff
    HexOff
  9. 必须在这 3 个宏命令下方添加用于此重新格式化任务的宏代码行.
  10. 点击按钮关闭并使用按钮确认更新宏的问题.
  1. Click in UltraEdit in menu Macro on menu item Edit Macro.
  2. Click on button New macro.
  3. Enter as macro name for example ReplaceEntities.
  4. Uncheck macro property Show cancel dialog for this macro.
  5. Let macro property Continue if search string not found checked.
  6. Assign a hotkey or chord for quick execution by key if this is wanted for quick macro execution by key in future.
  7. Click on button OK.
  8. Back in Edit/Create Macro, there is now the new macro selected with 3 lines already present in edit field with the macro commands:
    InsertMode
    ColumnModeOff
    HexOff
  9. Below those 3 macro commands must be added for this reformatting task the macro code lines posted below.
  10. Click on button Close and confirm the question to update the macro with button Yes.

宏就可以使用了

  • 通过指定的热键/和弦,
  • 在通过视图 - 视图/列表 - 宏列表打开的宏列表中双击它,以防它不可见(停靠或浮动),或者
  • 使用宏 - 任意/多次播放.
  • by assigned hotkey/chord,
  • by double clicking on it in Macro List opened via View - Views/Lists - Macro List in case of not being already visible (docked or floating), or
  • by using Macro - Play Any/Multiple Times.

此外,宏 - 再次播放可以非常频繁地使用,具体取决于上次执行的是哪个宏.

Also Macro - Play Again can be very often used depending on which macro was last time executed.

除了对话框中已经存在的 3 个标准命令之外,还需要替换整个活动文件 HTML 实体的宏代码例如:

The macro code required additionally to 3 standard commands already present in the dialog to replace in entire active file HTML entities is for example:

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 "Ã"

需要使用宏 - 全部保存将此 UE 宏(不带或带其他 UE 宏)保存到宏文件中.

It is necessary to save this UE macro (without or with other UE macros) into a macro file by using Macro - Save All.

为了稍后再次使用这个宏(和其他宏存储在同一个宏文件中),需要使用宏 - 加载加载宏文件.

For using this macro (and other macros store in same macro file) later again, it is necessary to load the macro file using Macro - Load.

使用宏 - 设置自动加载,可以选择在 UltraEdit 启动时自动加载的宏文件,以便该宏文件中的宏从一开始就可用,而无需显式加载宏文件.

With Macro - Set Auto Load it is possible to select a macro file for being automatically loaded on startup of UltraEdit so that the macros in this macro file are available from beginning without an explicit loading of the macro file.

以后也可以使用宏 - 删除宏/修改属性来更改宏属性.在更改宏代码或其属性后,不要忘记使用宏 - 全部保存,以将更改保存在宏文件中.

The macro properties can be also changed later by using Macro - Delete Macro/Modify Properties. Don't forget to use Macro - Save All after making a change to a macro code or its properties to save this change in macro file, too.

UltraEdit 脚本使用 JavaScript 核心引擎.UltraEdit 脚本是一个 ASCII/ANSI 文本文件,其中包含 JavaScript 核心代码和额外的 UltraEdit 相关脚本命令.这意味着 UltraEdit 脚本可以像任何其他文本文件一样直接编写,并且不得在对话框中进行编辑.

UltraEdit scripts make use of the JavaScript core engine. An UltraEdit script is an ASCII/ANSI text file containing JavaScript core code with additional UltraEdit related scripting commands. This means an UltraEdit script can be written directly like any other text file and must not be edited in a dialog.

与上述宏完全相同的 UltraEdit 脚本是:

An UltraEdit script which makes exactly the same as the macro above would be:

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.

Such an UltraEdit script should be saved with file extension .js, for example ReplaceEntities.js.

保存 UE 脚本后,可以通过 Scripting - Scripts 将其添加到 脚本列表,并为脚本添加简短描述并为其分配热键/和弦按键快速执行的脚本.

Once an UE script is saved, it can added via Scripting - Scripts to the Script List with adding a short description for the script and assigning a hotkey/chord to the script for quick execution by key.

脚本就可以使用了

  • 通过指定的热键/和弦,
  • 在通过视图-视图/列表-脚本列表脚本-脚本列表打开的脚本列表中双击它,以防万一不可见(停靠或浮动),或
  • 通过点击菜单脚本中的脚本文件名.
  • by assigned hotkey/chord,
  • by double clicking on it in Script List opened via View - Views/Lists - Script List or Scripting - Script List in case of not being already visible (docked or floating), or
  • by clicking on script file name in menu Scripting.

如果 UE 脚本是活动文件并且它被编写为不在活动文档上运行,则还可以使用 脚本 - 运行活动脚本 来执行该脚本.但是大多数像上面这样的脚本都是为了在活动文件上运行而编写的,因此需要将脚本文件添加到脚本列表中才能执行.

If an UE script is the active file AND it is written to run NOT on active document, the script can be also executed with Scripting - Run Active Script. But most scripts like the one above are written to run on active file and therefore requires adding the script file to the script list for execution.

JavaScript 的核心对象和函数并未在 UltraEdit 中的任何地方记录,尽管它们也可以在 UltraEdit 脚本中使用.可以在 Mozilla Developer 站点上找到有关核心功能的文档.

The core objects and functions of JavaScript are not documented anywhere within UltraEdit although they can be also used in UltraEdit scripts. The documentation for the core features can be found on Mozilla Developer site.

UltraEdit 的附加脚本命令记录在 UE 帮助页面,标题为 脚本命令.另外还有 View - Views/Lists - Tag List 包含标签组 UE/UES Script CommandsUE/UES Macro Commands 以便快速在当前插入符号位置的活动文件中添加 UE 的脚本或宏命令.

The additional scripting commands of UltraEdit are documented in help of UE on page with title Scripting commands. There is additionally View - Views/Lists - Tag List containing the tag groups UE/UES Script Commands and also UE/UES Macro Commands for quick adding a scripting or macro command of UE in active file at current position of the caret.

这篇关于搜索并替换为术语列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆