Note: F is a key on your keyboard not the input "F" which would be Shift+F
There's no inline, rich command-line editing within Vim in the way many might expect (i.e. like Bash command-line editing with "vi-mode") but you can edit commands with a feature that is arguably even better than that; a feature that even lets you yank/put parts of earlier commands into your in-progress command.
I'm talking about the command-line window.
To open this while in the middle of entering a command (after you hit :
) type Ctrl+F
You will see your full Ex command history including your in-progress command. This window is like a regular Vim buffer; you'll start out in Normal mode and can edit your current command or any previous commands the same way you'd edit any other text.
When you're ready to submit a command make sure the cursor is on its line, and hit Enter. (Doesn't matter what mode you're in.)
If you want to bail out without submitting any command you can just use :q
to quit the command-line window. (You don't need !
, even if you made changes).
Or, if you want to continue editing a command back on the regular command-line hit Ctrl+C with the cursor over the correct command.
BTW, you can also open this window from any buffer by entering q:
while in Normal mode.
Finally, you have this same capability for editing search patterns: q/
or q?
.
See :h cmdwin
for complete details.
Ctrl-F
and you'll enter a mode with full Vim edit capabilities of current and previous commands.:h c_CTRL-F
... I think there's already an answer for this somewhere...Ctrl-F
from a command-line or search to open the "command window", where you can use Normal and Insert modes to edit your command. See:help c_CTRL-F
. I believe there's a recent question that got the same answer recently, so I'm looking for that to mark this one as a duplicate... If I don't find it, I might post it as an answer here.