【转】Emacs中的文件操作:dired mode

2019-04-22  本文已影响0人  p1uxtar

在了解了dired mode后,今天才遇到需要使用的实例:将多个文件重命名并修改扩展名。

用到了标记的操作m,与未标记互换的t,以正则方式替换文件名的% R,均学习自这篇文章

DIRctory EDitor, emacs中的文件管理器.
dired是直接对硬盘文件进行操作,三思而后行!

注 :
[]中的符号的意义
[*] 作用在已标记的所有文件(目录)或光标所在当前文件(目录)上。
[p] 用前缀参数表示文件个数,从当前文件开始,正数向下、负数向上。
[u] 用前缀参数改变默认行为。对于设置标记的命令一般变为去掉标记。
[x] 需要加载 dired-x。

1. 查看帮助

2. 移动光标

3. 标记文件

4. 复制、移动、创建 文件或目录以及连接

5. 修改文件名、属性

6. 访问文件,目录

7. 退出

8. 隐藏/刷新缓冲中内容

9. 其他

10. dired-x.el 中的其他有用的函数

应用实例:交互查找替换多个文件中的字符串

  1. Call dired to list files in dir, or call find-dired if you need all sub directories;

  2. Mark the files you want. You can mark by regex by typing 【% m】.

  3. Type Q to call “dired-do-query-replace-regexp”.

  4. Type your find regex and replace string.

  5. For each occurrence,

    • y to replace
    • n to skip
    • Ctrl+g to abort the whole operation
    • ! to replace all occurrences in current file without asking
    • N to skip all possible replacement for rest of the current file
    • YTo do the replacement on all files without further asking
  6. Call ibuffer to list all opened files. Type * u to mark all unsaved files, type S to save all marked files, type D to close them all.

这篇博文应该是更全面的解释。

上一篇下一篇

猜你喜欢

热点阅读