emacs: Indirect Buffers

Say you have buffers A and B both visiting the same file. Sure, you can view different parts of this file in A and B, but once you narrow in one buffer, the same section is narrowed in the other.

When this is not the behaviour you want (when would you actually want this behaviour, is the real question imho), use indirect buffers!

An indirect buffer shares the text of some other buffer, which is called the base buffer of the indirect buffer. In some ways it is a buffer analogue of a symbolic link between files.


The text of the indirect buffer is always identical to the text of its base buffer; changes made by editing either one are visible immediately in the other. But in all other respects, the indirect buffer and its base buffer are completely separate. They can have different names, different values of point, different narrowing, different markers, different major modes, and different local variables.

Handy-dandy key chord C-x 4 c (clone-indirect-buffer-other-window): analogous to C-x 4 f, this binding creates an indirect buffer of the current buffer in another window. (Remember that c by remembering clone.)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s