VIM Executing a key command in a function
The general answer is to use the :normal
command, like
:exe "normal \<C-W>\<C-w>"
The :execute
approach is the readable way to get :normal
to recognize special characters like control-key combinations. The other approach is
:normal ^W^W
where each^W
is one character inserted by typing Ctrl-vCtrl-w.