我有一个函数,我想执行一个键盘命令,但出现错误尾随字符:
function! MyFunction()
if condition
<C-W><C-W>
else
:some_other_command
endif
endfunction
Run Code Online (Sandbox Code Playgroud)
它不喜欢 <CW><CW>
我可以用什么代替?
jw0*_*013 28
一般的答案是使用:normal
命令,如
:exe "normal \<C-W>\<C-w>"
Run Code Online (Sandbox Code Playgroud)
该:execute
方法是:normal
识别特殊字符(如控制键组合)的可读方式。另一种方法是
:normal ^W^W
Run Code Online (Sandbox Code Playgroud)
其中每个^W
都是通过键入插入的一个字符Ctrl-vCtrl-w。