开发者

Buffer switching in Emacs

开发者 https://www.devze.com 2023-03-22 12:15 出处:网络
I would like to emulate Alt-Tab as it works with individual windows on GTK, but with Ctrl-Tab within buffers in emacs.

I would like to emulate Alt-Tab as it works with individual windows on GTK, but with Ctrl-Tab within buffers in emacs.

So, for example, if I have ten buffers open in emacs, and I am working on two at the moment, say Buffer1 and Buffer2, and I am in Buffer1 currently, I would like Ctrl-Tab to take me to Buffer2, and on pressing Ctrl-Tab again, back to Buffer1.

In case I need to go to Buffer3, or Buffer4 etc, I keep Ctr开发者_如何学Cl pressed while I press Tab.

Does this make sense? If so, please tell me how I can do this.


What are you using currently?

But I think

(global-set-key (kbd "C-<tab>") 'next-buffer)
(global-set-key (kbd "C-S-<tab>") 'previous-buffer)

should be doing what you describe.

As jaybee comments, it may be a whole less useful than in, say, Firefox. But I'd recommend ido-switch-buffer.

This may also be of interest: http://www.emacswiki.org/emacs/ControlTABbufferCycling


I think swbuff works well. See http://www.emacswiki.org/emacs/SwBuff.

From my init file:

(require 'swbuff)
(global-set-key [(control tab)] 'swbuff-switch-to-next-buffer)


Switch between the two most recent buffers

(global-set-key [\C-tab]
        (lambda () (interactive)
          (switch-to-buffer (other-buffer))))


I'm quite happy with this setup:

(defun next-line-cycle ()
  "Go to next line. Go to first line if end is reached."
  (interactive)
  (revert-buffer)
  (if (= (line-number-at-pos) (count-lines (window-start) (window-end)))
      (backward-page)
    (forward-line)))
(defun ctrltab ()
  "List buffers and give it focus"
  (interactive)
  (if (string= "*Buffer List*" (buffer-name))
      (next-line-cycle)
    (progn (list-buffers)
       (switch-to-buffer "*Buffer List*")
       (delete-other-windows)
       (forward-line))))
(global-set-key [C-tab] 'ctrltab)

Usage pattern:

* hold ctrl, press <tab> once, keep holding ctrl
* press 'm' to view currently selected buffer
* press <tab>(possibly more times) to select next buffer

This works well when you don't want to enter the buffer name (e.g. ido-mode) to switch (maybe a cup of coffee in the right hand).


Sounds like you would like to try out iflipb:

(require 'iflipb)
(global-set-key (kbd "<C-tab>") 'iflipb-next-buffer)
(global-set-key (kbd "<C-S-iso-lefttab>") 'iflipb-previous-buffer)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号