Killing buffers whose names start with a particular string

前端 未结 6 1047
太阳男子
太阳男子 2020-12-31 05:41

Here\'s my problem: I use Emacs and get lots of buffers that are pretty useless all the time, like *Messages* or *Completions*.

I want to bind \\C-y to close all buf

6条回答
  •  梦毁少年i
    2020-12-31 06:42

    It can be a good idea to see what you will delete before deleting it, to play safe.

    In Icicles, by default C-x k is a multi-command that you can use to kill any number of buffers that match your minibuffer input. In this case, you would type * TAB to see all buffer names starting with * as completion candidates.

    You can then narrow the matches, in several ways. When all of the matches remaining are what you want, hit C-! to delete all of those buffers.

    In the case you presented, you do not want to delete buffers named *shell.... So after * TAB you would hit S-SPC and then enter another pattern to match: shell, then S-TAB. That narrows to only the *shell... buffers that you do not want to kill. You then hit C-~ to subtract those matches (complement). That leaves all of the buffers except the shell buffers. Hit C-! and they're all killed.

    You can also kill individual buffers by just control-clicking their names in *Completions*: C-mouse-2.

    More generally, in Icicles every multi-command that reads a buffer name lets you use S-delete (Shift + the Delete key) to kill buffer candidates.

    http://www.emacswiki.org/emacs/Icicles_-_Multi-Commands

    http://www.emacswiki.org/emacs/Icicles_-_More_About_Multi-Commands

提交回复
热议问题