4

Say I entered :e bla/bla/bla.txt and I realize I want to put a ! after the e. Can I get there without using the arrow keys?

5

Command Line Window

You can use cmdline-window to edit the command line the same way as you would any other window. Enter into this window by pressing <c-f> while on the command line or use q: in normal mode.

There is a similar Vimcasts episode on the subject: Refining search patterns with the command-line window

Command line mappings

The command line also has many of its own mappings to help navigate/modify:

  • <c-b>/<home> to go to the beginning (Some people remap this to <c-a> to match emacs/bash/readline)
  • <s-left> or shift + left arrow moves to the left one WORD
  • <c-u> clears the command line completely
  • <c-r>{reg} will put the value of register, {reg} into the line
  • Many more. See Q_ce for a quick review.

For more help see:

:h cmdwin
:h cmdline-editing
| improve this answer | |
  • I didn't know about <c-f>, but I found that using <Esc> followed by q: showed me the unfinished ex mode command in my command line window. – Wildcard Mar 11 '16 at 4:09
1

From :h cmdline:

CTRL-B or <Home>                                c_CTRL-B c_<Home> c_Home
            cursor to beginning of command-line
CTRL-E or <End>                                 c_CTRL-E c_<End> c_End
            cursor to end of command-line

I didn't see any other commands that "jumped" around and didn't use arrow keys. You could do: HomeDel, then type e! (a bit convoluted, I agree).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.