emacs批量替换

  1. 使用dired显示文件列表。

    dired.png

  2. 选择文件

    • m for mark
    • u for unmark
    • U for unmark all
    • 执行 dired-mark-files-regexp 正则匹配文件

    mark.png

  3. 交互式替换

    执行dired-do-query-replace-regexp

    • y to replace current highlighted occurrence
    • n to skip
    • C-g to abort
    • ! to replace all occurrences in current file without more asking
    • N to skip all possible replacement for rest of the current file
    • Y to do the replacement on all files without further asking