Using normal-mode motions in command-line mode in Vim

in vim's command line mode: <ctrl-w> deletes a word

in normal mode: q: goes to the command history (which can be edited with vim commands)

see :help cmdline-editing and :help cmdline-window for more commands.


By default you can press Control + f (or otherwise see set cedit) when on the Vim command-line, which opens the command-line window where you can edit the command using normal-mode Vim editing keys. Enter will run the command or Control + c will return you to the standard command-line.

So in your specific example, you could press Control + f on the Vim command-line then db and it would do what you want.

When I have to do more sophisticated editing commands I use the above approach because I'm more familiar with Vim editing keys than I am with the alternatives. I also find the normal-mode vim keys more powerful.

See :help c_ctrl-f for more information.

Tags:

Vi

Vim