Using C-x 4 in Emacs

Marcin Borkowski (mbork) has an interesting post on the Emacs C-x 4 bindings. My normal Emacs window configuration is two side-by-side windows in a full screen frame and my workflow often involves opening related buffers in the two windows so I am constantly using commands like find-file-other-window (Ctrl+x 4 f) and switch-to-buffer-other-window (Ctrl+x 4 b). All that’s by way of saying that I’m pretty familiar with the Ctrl+x 4 bindings. Nevertheless, I learned some new things from Borkowski’s post.

One of those new things is display-buffer (Ctrl+x 4 Ctrl+o). It’s sort of like find-file-other-window except that it doesn’t switch focus. That’s handy if you want to open a file in the other window but keep working in the current window.

Another new command I learned is clone-indirect-buffer-other-window (Ctrl+x 4 c). Cloning buffers is something I rarely do so I always forget the exact commands. This makes it easy to clone a buffer with a single key sequence.

Finally, there’s an infelicity. I always think of Ctrl+x 4 as meaning perform an action in the other window. Indeed, if you’re using which-key, and you should be, you’ll see that all the Ctrl+x 4 completions do perform some action in the other window. All, that is, except Ctrl+x 4 0. You’d think that it would delete the other window but it does something entirely different. It deletes the current window and its associated buffer. To my mind, that’s a blatant violation of the principle of least surprise.

Take a look at Borkowski’s post. He discusses additional Ctrl+x 4 commands and provides a deeper explanation of some of the commands I’ve mentioned.

This entry was posted in General and tagged . Bookmark the permalink.