A quick way to do find-file in Emacs?

巧了我就是萌 提交于 2020-01-03 15:53:10

问题


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.


回答1:


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




回答2:


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




回答3:


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.




回答4:


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.




回答5:


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

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




回答6:


(defun foo ()
  "Clear the minibuffer"
  (interactive)
  (delete-minibuffer-contents))

(define-key minibuffer-local-map [(meta ?k)] 'foo)


来源:https://stackoverflow.com/questions/5125635/a-quick-way-to-do-find-file-in-emacs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!