views:

879

answers:

5

Question: For typed in commands invoked via M-x I am having difficulty understanding how Emacs allows recalling and rerunning the commands. The command-history works quite differently from Vim. It puts the commands in a buffer rather than the "minibuffer".

Is there a way to get something similar to Vim's approach (i.e., previously typed commands can be scrolled through simply using the arrow up-down keys)?

Any tips or links to tutorials or recommended add-on code is appreciated.

A: 

Call

customize-group minibuffer

It will show you an option History Length (it's 30 by default here). If you want to save your history across emacs sessions, see

customize-group savehist

You can use the normal arrow keys up / down to navigate through the history.

Johannes Schaub - litb
Can someone tell me how the downvote is judged? Changing the history length has a direct effect on being able to scroll through it, doesn't it? I would be glad to fix all errors.
Johannes Schaub - litb
+6  A: 

C-x ESC ESC, C-x M-ESC, or C-x M-: puts your history in the minibuffer, after which you can scroll back and forth as you ike with the arrow keys.

M-x list-command-history puts the whole history in a buffer from which you can execute commands.

C-x z repeats the last command.

Look at EMACS manual (info) section 9.4 Minibuffer History.

Charlie Martin
A: 

If you want to save history of commands (and many other parameters) between emacs sessions, you can use the desktop package, that is included into emacs distribution

Alex Ott
+1  A: 

M-p and M-n are the canonical history navigation keys in GNU software. Emacs is no exception; this works nearly everywhere where you can type something.

In the case of extended commands ("M-x commands"), hit M-x, then navigate freely throughout the history. You can also do a reverse history isearch with C-r, as in bash.

jrockway
+1  A: 

Not entirely sure I understand what you need, but have you tried Smex? I find it really handy, altho a bit slow on old computers.

monotux