I'm in the process of mapping MacOS keybindings (Cmd/Alt + arrows/backspace/delete) to Vim commands, and the only thing remaining is to make the movements in normal mode (such as
e) work in the command line :-)
Martin’s answer with
:normal[!] is great for running Normal commands from an Ex command.
Two other possible interpretations:
- In a (Normal-mode) mapping, the right-hand side is Normal mode. So
nnoremap <M-w> dbis fine if you can use Meta mappings.
- To use Normal-mode editing features on the Ex/
:command line, press
q:or Ctrl-f while already in
:. The latter works for searches as well and may be customized. For the former, cf.
The :normal command seems to be what you're looking for; there are two variants of this:
:normal may use custom mappings from your vimrc or plugins, if any, and
:normal! will always use the default built-in Vim mappings. For example, this will run
gj, which is usually unexpected:
nnoremap j gj normal j
You usually want to use
:normal! with the exclamation mark, unless you have a specific reason to use
To use modifiers or named keys, wrap it inside
:exe for short); for example:
exe "normal! \<C-x>\<C-u>"