开发者

A quick way to do find-file in Emacs?

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开发者_如何学Python you in advance.


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


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


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.


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.


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

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


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜