In Emacs, how do I select the completion list with the keyboard?

我的未来我决定 提交于 2019-12-01 02:27:27

问题


When I tab-complete in a minibuffer and Emacs displays a completion list in a new buffer, how do I switch to that buffer without using the mouse?

I tried C-x o, but that just switched to the first buffer, out of which I entered the minibuffer.

I also tried C-x b, but that gives me command attempted to use minibuffer while in minibuffer.

Lastly I tried C-x <C-right>, which gives me cannot switch buffers in minibuffer window.

EDIT: I spoke about minibuffer completion in my example, but being able to access the completion list (using the keyboard) from within a regular buffer is also important to me, and not working. The M-v shortcut was suggested, but it only seems to work inside the minibuffer accessed by M-x, in every other buffer I've tried, M-v is bound to scroll down command and does not switch to the completion list. I doesn't even seem to work in other minibuffers. For example, it doesn't work in the shell command minibuffer invoked by M-! either.


回答1:


You can use M-v (documented here) which switches to the completion buffer and puts the cursor on the first completion:

Typing M-v, while in the minibuffer, selects the window showing the completion list (switch-to-completions). This paves the way for using the commands below. <PageUp> or <prior> does the same. You can also select the window in other ways...

EDIT: It looks like based on your edit to the original question that what you're asking for is a way to switch to the completions buffer more globally. There is a function switch-to-completions that selects the completions list - you might consider binding that function to a key of your choosing, e.g.:

(define-key global-map (kbd "C-x t") 'switch-to-completions)

For example, such a binding allows me to switch to completions from "Shell command: " invoked by M-!, and places the cursor on the first possible completion.




回答2:


You can use C-xo twice, or use M--C-xo, which switches to the previous buffer instead of the next one.



来源:https://stackoverflow.com/questions/18084039/in-emacs-how-do-i-select-the-completion-list-with-the-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!