2010-11-09 105 views
3

有没有办法在缓冲区之间切换,而不必通过 缓冲区列表或写入我想要切换到的缓冲区的名称?更具体的我不知道Emacs可以缓冲区之间标签就像它是如何在记事本工作++缓冲区之间的Emacs选项卡

+2

这个问题也问(并回答不同)以上的超级用户:http://superuser.com/questions/208871/emacs-tab-between-buffers – jwernerny 2010-11-09 13:50:19

+1

我试过很多,并最终停在一个简单的iflip包http://www.emacswiki上。org/emacs-ja/iflipb随着时间的推移,你会发现几乎没有比“C-x b”更好的切换+ ido-mode – VitoshKa 2010-11-09 21:18:38

回答

4

Emacs的22.1及更高supportsprevious-bufferC-x <left arrow>)和next-bufferC-x <right arrow>)命令。

可以使用this script将这两个命令添加到较老的Emacsen。

+0

是否还有一个命令可以在最近的命令之间切换? – starcorn 2010-11-09 11:41:39

+0

是的,请参阅我的答案中第一个链接中的“在两个最近使用的缓冲区之间切换”部分。 – 2010-11-09 11:43:00

3

我从来没有最终使用CX <权>CX < C-右>了,因为我觉得他们繁琐重复,如果我想过去的周期超过一个缓冲区,所以我刚刚写了一对夫妇的功能,让你继续切换到next/previous-buffer< C-右>< C-左>如果最后的命令也是一个next/previous-buffer命令。

例如C-X < C-左> < C-左> < C-左> < C-右> < C-左>将带您回到三个缓存器,向前,向后一次。

我所做的假设,即< C-左> & < C-右>通常势必forward/backward-word,和我呼吁那些明确作为后备。

(defun my-forward-word-or-buffer-or-windows (&optional arg) 
    "Enable <C-left> to call next-buffer if the last command was 
next-buffer or previous-buffer, and winner-redo if the last 
command was winner-undo or winner-redo." 
    (interactive "p") 
    (cond ((memq last-command (list 'next-buffer 'previous-buffer)) 
     (progn (next-buffer) 
       (setq this-command 'next-buffer))) 
     ((memq last-command (list 'winner-redo 'winner-undo)) 
     (progn (winner-redo) 
       (setq this-command 'winner-redo))) 
     (t ;else 
     (progn (forward-word arg) 
       (setq this-command 'forward-word))))) 

(defun my-backward-word-or-buffer-or-windows (&optional arg) 
    "Enable <C-left> to call previous-buffer if the last command 
was next-buffer or previous-buffer, and winner-undo if the last 
command was winner-undo or winner-redo." 
    (interactive "p") 
    (cond ((memq last-command (list 'next-buffer 'previous-buffer)) 
     (progn (previous-buffer) 
       (setq this-command 'previous-buffer))) 
     ((memq last-command (list 'winner-redo 'winner-undo)) 
     (progn (winner-undo) 
       (setq this-command 'winner-undo))) 
     (t ;else 
     (progn (backward-word arg) 
       (setq this-command 'backward-word))))) 

(global-set-key (kbd "<C-left>") 'my-backward-word-or-buffer-or-windows) 
(global-set-key (kbd "<C-right>") 'my-forward-word-or-buffer-or-windows) 
1

(我用Icicles缓冲区交换,我自己,但是......)

如果你想重复以前的命令任意次数,只要使用CX ZZZZZZ ......在这种情况下,例如,CX离开CX ZZZ ......

如果真是太麻烦了,绑定(next|previous)-buffer以外,重复键,如其他人所说。

但可重复的钥匙需求量很大。如果你不想浪费任何东西,你甚至可以把这些命令放在一个前缀键上,这样,例如,你可以这样做,例如,Cx左上角的左边 ......这是一个诀窍,在Bookmark+代码):

 

    (defun my-repeat-command (command) 
     "Repeat COMMAND." 
     (let ((repeat-message-function 'ignore)) 
     (setq last-repeatable-command command) 
     (repeat nil))) 

    (defun my-next-whatever-repeat (arg) ; `C-x right' 
     "Jump to the Nth-next whatever. 
    N defaults to 1, meaning the next whatever. 
    Plain `C-u' means start over at the first whatever (and no repeat)." 
     (interactive "P") 
     (require 'repeat) 
     (my-repeat-command 'next-whatever)) 

    (define-key ctl-x-map [right] 'my-next-whatever-repeat