Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a function, and I want to execute a key command, but I get the error Trailing characters:

function! MyFunction()
  if condition

It doesn't like the <C-W><C-W>

What can I use instead?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.