Edit an old command like buffer text
q:
Example
Normal mode. Most recent Ex command: s/old/new/. Current line contains old.
Before
History command: s/old/new/
Current buffer line: old
- q: Command history opens · cursor on the final blank row
- k$hciwfresh<Esc> Select the previous command and edit it · s/old/fresh/
- <CR> Run edited command · old becomes fresh; history closes
After
Edited command: s/old/fresh/
Current buffer line: fresh
Details & Vim help
Open Ex command history in a window with Normal-mode editing.
Repair a long command using the same editing skills as ordinary text.
q: differs from :q. It cannot open during macro recording because q stops the recording. Executing a history line can write files or run shell commands.
Edit the command in the history window, then press Enter to execute that line.
Try it in Vim
- From Normal mode, type q:.
- Move to a historical command and edit it.
- Press <CR> to execute that line, or :q<CR> to close without executing.