Emacs: help me understand file / buffer management

I have been using emacs for all my text editing needs over the past three years. When I'm in the same file, working on code or something else, I'm quite effective. With two files, I can "Cx b RET" between them, and I'm fine. However, when I need to work on more than two files at a time, I tend to get lost.

Here are some of the issues that I would like to work on:

  • I forgot that some of my buffers are being called, but I don’t understand why Cx Cb splits my window into two buffers and exits the mini-buffer. Of course, I can switch buffers and choose a buffer to visit, but it seems unintuitive and leaves me with two buffers.

  • When I visit a directory, not a file, I have a convenient list of all files and directories. Usually I want to do one of two things: 1) open one file and never see this buffer again OR 2) open a bunch of files and never see this buffer again. I really don't know how to do this, since moving a point to a file and going back to the left do not do any of these things.

  • I know that my buffers are not like tabs, but I have a desire to scroll through them to find what I want. I don't know any key bindings for this, but I would like it to be Mn / Mp or the like. Again, this can be a terribly inefficient way to switch buffers.

  • When I open any type of online help (for example, in ESS), I have the habit of switching back to the buffer I was working in and using Cx 1 to return to one buffer. However, when I do this, the help buffer hangs in my list of buffers, which confuses me even more. I know that I can switch to this buffer, kill it, switch back, and then go back to one buffer, but that seems wrong.

The way I have done this so far involves using the window manager and multiple emacs windows in different workspaces, rather than actually finding out the best way to manage multiple files in emacs. I don’t necessarily want to change emacs to better suit my needs (although I am open to this if it matches what I'm going to say) instead I would like to reflect on the file processing process / buffers what emacs does and how I can be more effective with it.

Any answer that helps me figure out the right way, or a more efficient way to manage my buffers or files, is welcome.

+29
emacs
Jun 29 2018-10-10T00:
source share
6 answers

I think you will really like Ido for working with several buffers whose names you definitely cannot remember. When you type Cx b , it displays a list of open buffers in most used orders. When you enter some characters in the buffer name, the list is filtered. The characters you enter should not be on the begging name or adjacent. Using the Cf , Cb buttons or the left / right arrow keys, they cycle through the choice of the buffer.

Also see Smex for similar Ido functions for Mx

Windows are Cx 0 using Cx 0 . Intentionally splitting a window is performed using Cx 2 for horizontal, Cx 3 for vertical. I like this feature, as it allows me to simultaneously display test and production code. Cx o will bring me to another window.

+17
Jun 29 '10 at 23:44
source share
  • Bind Cx Cb to the ibuffer . This is the best way to list buffers with many advanced features, and its default behavior is to replace the current buffer with a list of buffers, and then bury the list when selecting a buffer (leaving you with the newly selected buffer instead of the original one).

    You can simply use Cx b to enter your selection into the mini-buffer, of course; however, doing tabs (which is necessary in order to make this a viable option, IMO) temporarily opens a new window, and at this point I think you could also become familiar with something with a lot of features.

  • Use a instead of RET when choosing from dired. This kills a noisy buffer instead of leaving it behind. Ch m in any buffer will show you help for the main mode (followed by help for secondary modes), and you can read about all the available key bindings.

  • http://www.emacswiki.org/cgi-bin/wiki/TabBarMode ? (edit: I prefer Rémi's answer for this, but TabBarMode will give you a visual tab element if you are particularly interested in this.)

  • q tied to the quit function in a large number of basic modes. As a rule, he buries the buffer, and does not kill him, but I, of course, think that is good.

To get a little understanding of # 1, ibuffer has many nice features, and the Mx customize-group ibuffer RET will give you some insight into how you can customize it to your liking.

In addition, you can filter the buffer list by many criteria (again, use Ch m to view the help page), and then generate the definition of the “group” from the current filters and save your custom filters and groups for future use.

For example:

  • / f ^/var/www/ RET : filter buffer list to display only file names starting with /var/www/ .
  • / s Web filters RET : name and save the active filter installed in the initialization file.
  • / g Web development RET : create a named group from active filters.
  • / S My groups RET : name and save the group definitions in the initialization file.
  • / r Web filters RET : call web filter filters.
  • / R My groups RET : Call My Groups.
  • RET for the group name to collapse or expand it.
  • Ck and Cy to kill and destroy groups in order to organize them.
  • Ch m for more information ...

This way you can run one instance of Emacs and create filters and groups for different tasks and easily switch between them.

+18
Jun 30 2018-10-10T00:
source share

I use Cx right (or Cx C-right ) and Cx left (or Cx C-right ) to go to the next and previous buffers. I no longer mind the few buffers that lie in Emacs, but you can use k in the buffer list to kill a buffer that you no longer use.

+4
Jun 30 2018-10-10T00:
source share

You can also try Iswitchb mode , which provides automatic filling of buffer names when switching buffers through Cx b .

To activate:

 Mx iswitchb-mode 

Or add to the .emacs file:

 (iswitchb-mode) 

It is similar to Ido mode for switching a buffer, but a bit lighter.

Also, if you need a more customizable list of your buffers, use Mx bs-show as an alternative to Cx Cb . In this buffer, type ? to get a list of actions you can follow.

+4
Jun 30 '10 at 17:20
source share

I think the first most useful extension for flipping buffers is Anything . It allows you to type part of the name of the buffer (or file!), And it will determine what you want. I bounce Cx b at all for buffers. It makes life a lot better.

+2
Jun 30 '10 at 4:37
source share

As always, there are many ways to help you with this; it depends a bit on personal preferences, which works best, here are some links with explanations:

  • ibuffer ; which is an updated buffer menu (Cx Cb)
  • ido , which allows you to have more powerful autocomplete for switching buffers. This is a kind of "best iswitchb".

These two are enough for me; but you may also be interested in tabbar-mode , which gives you rudimentary tabs (for example, they have Firefox).

+2
Jul 01 '10 at 5:51 on
source share



All Articles