vimtricks.wiki Concise Vim tricks, one at a time.

How do I switch from the active command line into the command-line window to edit the command with full Vim power?

Answer

<C-f> (in command line)

Explanation

Pressing <C-f> while you are already typing in the Vim command line (:), search line (/ or ?), or input prompt switches you into the command-line window with the current in-progress text pre-loaded. This is subtly different from q: (which opens the window from normal mode starting at history) because it preserves the command you were actively typing.

How it works

  • While typing in the command line, press <C-f> to jump into the command-line window
  • The current in-progress input appears as the last line, ready to edit with full Vim motion and operator support
  • Press <CR> on any line to execute that command
  • :q or <C-c> closes the window and returns to normal mode without executing

Example

You start typing a complex substitution:

:s/very_long_pattern_here/

You realize you need to use Vim's full editing power to finish the replacement string. Instead of and retyping from scratch:

  1. Press <C-f> — the command-line window opens with :s/very_long_pattern_here/ already in it
  2. Edit freely with A, i, cw, any Vim commands
  3. Press <CR> to execute

Tips

  • Works identically for search: press <C-f> while typing a / search to enter the search command-line window
  • q: / q/ / q? open the same windows from normal mode but start at the most recent history entry
  • Inside the command-line window, <C-c> returns to the original command line with your text intact

Next

How do I create new files and directories directly inside Vim's built-in file browser without leaving Vim?