在 Emacs 中查找文件的快速方法?

发布于 2024-10-19 11:10:49 字数 155 浏览 2 评论 0原文

每次我在 Aquamacs 或 Emacs 中使用 find-file 时,它​​都会自动显示上一个目录,例如 ~/Work/abc/cdf。但是,如果我想从 ~ 目录中打开某些内容,我必须一直按删除键直到第一个字符。有没有什么快速方法可以只用一两个键替换所有字符串?

先感谢您。

Every time I use find-file in Aquamacs or Emacs, it auto shows the previous directory, for example ~/Work/abc/cdf. However, if I want to open something from the ~ directory, I have to press Delete all the ways down to the first character. Is there any quick way to replace all the string with just one or two keys?

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

千と千尋 2024-10-26 11:10:49

不,您不需要(必须按删除键)。只需输入 ~,emacs 就会忽略它之前的所有内容。与/相同。

No, you don't (have to press Delete). Just type ~ and emacs will ignore everything before it. Same with /.

被你宠の有点坏 2024-10-26 11:10:49

是的,当仍在迷你缓冲区中时,按 Ctrl-A 转到文件名路径的开头,然后按 Ctrl-K 将其删除到行尾,现在您的文件路径为空,您只需键入“~” ”

Yes, while still in the mini buffer press Ctrl-A to go to the start of the file name path, and Ctrl-K to delete it to the end of the line, now your file path is empty and you can just type "~"

寄与心 2024-10-26 11:10:49

正如 harpo 已经指出的那样,只需输入 ~ 即可快速更改到主目录。更一般地说,您可以通过激活 ido-mode

As harpo has already noted, just entering ~ will do the job for changing to home directory quickly. More generally, you can get a lot of improvements for quicker navigation in find-file by activating ido-mode.

静水深流 2024-10-26 11:10:49

M- (backward-kill-word)

应该在每个目录级别按一次

Cx (backward-kill-sentence)

可以工作,但是还删除了 ~/

您当然可以定义自己的命令和 emacs lisp 来实现它们。

作为一种替代方法,许多 UNIX 会让您只需在预填充路径后键入 ~/ ,然后将所需的路径放在后面, ~/ 会覆盖之前的所有内容。

how about M-<DEL> (backward-kill-word)

Should take one press per directory level

C-x <DEL> (backward-kill-sentence)

works but also wipes out the ~/

You can of course define your own commands and the emacs lisp to implement them.

As an alternate approach, many unixes will let you simply type a ~/ after the prefilled path and put your desired path after that, the ~/ overriding everything that came before.

世俗缘 2024-10-26 11:10:49

有一些软件包可以为您做到这一点,例如:

http://www.emacswiki .org/emacs/minibuf-electric-gnuemacs.el

There are packages that does that for you, for example:

http://www.emacswiki.org/emacs/minibuf-electric-gnuemacs.el

长安忆 2024-10-26 11:10:49
(defun foo ()
  "Clear the minibuffer"
  (interactive)
  (delete-minibuffer-contents))

(define-key minibuffer-local-map [(meta ?k)] 'foo)
(defun foo ()
  "Clear the minibuffer"
  (interactive)
  (delete-minibuffer-contents))

(define-key minibuffer-local-map [(meta ?k)] 'foo)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文