Emacs: Switching Between Buffers with the Same Name but in Different Directories

↘锁芯ラ 提交于 2019-12-01 04:43:57

Use uniquify. I use it like that:

(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)

Expanding on Tomasz's answer.

There are other options for uniquify-buffer-name-style, besides forward, that you may consider:

Files /foo/bar/mumble/name and /baz/quux/mumble/name would have the following buffer names in the various styles:

forward        bar/mumble/name  quux/mumble/name
reverse        name\mumble\bar  name\mumble\quux
post-forward   name|bar/mumble  name|quux/mumble
post-forward-angle-brackets   name<bar/mumble>  name<quux/mumble>

If you want to strip common directory suffixes of conflicting files, add the line below to your emacs init file.

(setq uniquify-strip-common-suffix t)

Now, if you open /a1/b/c/d and /a2/b/c/d, the buffer names will say "d|a1" and "d|a2" instead of "d|a1/b/c" and "d|a2/b/c".

Use lusty explorer. Configure it with:

(require 'lusty-explorer)

;; Override the normal file-opening and buffer switching.
(global-set-key (kbd "C-x C-f") 'lusty-file-explorer)
(global-set-key (kbd "C-x b")   'lusty-buffer-explorer))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!