emacs - 如何快速浏览 Emacs 中的大量文件?

标签 emacs dired

有没有办法在 Emacs (24.3) 中快速浏览大量文件?进一步来说:

让我们假设一个 Emacs 框架被分成两个窗口。假设焦点位于左侧窗口中,该窗口有一个打开的“dired”缓冲区,其中包含大量文本文件(或代码)。我想上下移动文件列表(例如使用光标键),同时当前文件显示在右侧窗口中。更好的是,只有当我在 dired 缓冲区中移动到下一个文件时,才会查看和关闭文件。这将非常有用,特别是与一些“省略”模式一起使用。

这可以在'dired'中完成吗?我也没有在 dired-x 或sunrise-commander 中找到这个功能。是否可以?

我已经尝试过的最佳候选人(以及为什么他们没有解决问题):

'v' 显示当前文件,但也移动了注意力

'C-o' 显示当前文件,但在向上或向下移动后,我必须再次按 C-o,它还会生成大量缓冲区

非常感谢你的帮助!

最佳答案

这是我如何使用 view-mode 执行此操作的方法:

(add-hook 'view-mode-hook
      (lambda()
        (define-key view-mode-map (kbd "n") 'dired-view-next)
        (define-key view-mode-map (kbd "p") 'dired-view-prev)))

(defun dired-view-next ()
  "Move to next dired line and view ."
  (interactive)
  (quit-window)
  (dired-next-line 1)
  (dired-view-file))

(defun dired-view-prev ()
  "Move to next dired line and view ."
  (interactive)
  (quit-window)
  (dired-next-line -1)
  (dired-view-file))

更新:

这个有两个 Pane :
(defun dired-view-next-pane ()
  (interactive)
  (other-window 1)
  (if view-mode
      (kill-buffer))
  (other-window -1)
  (dired-next-line 1)
  (view-file-other-window
   (dired-get-file-for-visit))
  (other-window -1))

关于emacs - 如何快速浏览 Emacs 中的大量文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19907939/

相关文章:

emacs key "deletechar"?

emacs - 如何在Emacs中的git grep命令中使用M-x rgrep?

emacs - 使用 Emacs 和 Cider 进行 Clojure 编码

sorting - 根据自定义比较器对 emacs dired 缓冲区进行排序

Emacs; C-x C-j 加载 dired 之前,dired-x

emacs orgmode 不在标题之间插入行?

c++ - 当我在Emacs中执行 'compile'命令时,如何自动给出当前缓冲区的文件名?

emacs - 如何在 Emacs 中解压/解压

emacs - Emacs 中每种模式的不同颜色主题

Emacs Dired使用相同的缓冲区