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

How do I edit a command in a full Vim buffer before executing it?

Answer

<C-f> from : prompt

Explanation

Pressing <C-f> while on the : command line opens the command-line window, where you can edit your command using full Vim editing capabilities.

How it works

  • Type : and begin a command
  • Press <C-f> to open the command-line window
  • Edit the command using normal Vim motions
  • Press <CR> to execute

Example

You start typing a complex substitute command and realize you need to edit the middle:

  1. Type :%s/very_long_pattern_name/
  2. Press <C-f> to open in a buffer
  3. Navigate and edit with full Vim power
  4. Press <CR> to execute

Tips

  • q: opens the command window directly with history
  • q/ opens the search history window
  • The command-line window is a regular buffer with special behavior
  • <C-c> closes the window without executing
  • This is invaluable for editing long, complex commands

Next

How do you yank a single word into a named register?