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

How do I change the key that opens Vim's command-line window?

Answer

:set cedit=<C-y>

Explanation

Vim's command-line window is invaluable for editing long : commands, search patterns, and complex substitutions with normal-mode tools. By default, opening it relies on a specific control-key chord that may conflict with terminal bindings or muscle memory. The 'cedit' option lets you remap that trigger to a key combination that is comfortable and available in your environment.

How it works

  • 'cedit' defines the key that opens the command-line window while entering a command
  • :set cedit=<C-y> remaps it to Ctrl+Y
  • Once set, start typing : and press <C-y> to jump into the full command-line window
  • In that window, you can use normal-mode motions, search, macros, and undo like any regular buffer

Example

Suppose you are composing a long substitution and need multi-line editing ergonomics:

:set cedit=<C-y>

Now type : and press <C-y> to open the command-line window, refine the command with normal-mode editing, then execute it with <CR>.

Tips

  • Pick a key that does not collide with terminal flow-control shortcuts
  • Add this to your vimrc/init.lua so it persists across sessions
  • If <C-y> is taken in your terminal, use another control key supported by your setup

Next

How do I make Vim sessions save global variables?