Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have two files with the same name but in different directories:

apples/main.cpp
oranges/main.cpp

I open them in one emacs window via emacs apples/main.cpp oranges/main.cpp

When I use C-x b to switch between these two buffers, the buffer names are "main.cpp" and "main.cpp<2>". I would love to be able to see the full path of these two files when switching buffers, so that I may disambiguate between the apples and the oranges version. Is there a way to do this?

One way could be to modify whatever code generates the <2> after the second main.cpp when Emacs detects that a buffer with that name is already open. However, I couldn't find how to do this.

like image 847
Alan Turing Avatar asked Apr 09 '11 20:04

Alan Turing


1 Answers

Use uniquify. I use it like that:

(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
like image 118
Tomasz Elendt Avatar answered Oct 01 '22 18:10

Tomasz Elendt