Reputation: 81
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 Ctrl pressed while I press Tab.
Does this make sense? If so, please tell me how I can do this.
Upvotes: 8
Views: 3851
Reputation: 904
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)
Upvotes: 2
Reputation: 20342
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).
Upvotes: 2
Reputation: 4026
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
Upvotes: 6
Reputation: 3734
Switch between the two most recent buffers
(global-set-key [\C-tab]
(lambda () (interactive)
(switch-to-buffer (other-buffer))))
Upvotes: 3
Reputation: 50947
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)
Upvotes: 3