如何映射包含vim中特殊字符的映射(例如或)?

时间:2021-07-20 06:13:44

I'm trying to map the enter key in Vim the first time to create a sort of... pre-mapping.

我试着在Vim中第一次映射enter键创建一个…pre-mapping。

This is basically want I want:

这基本上是我想要的:

nnoremap <cr> :nnoremap <cr>:!tmux send-keys -t :1.0 "py.test --cov" C-m <cr><cr>

But I want all of the <cr> (except the first one) to literally be like I typed <cr>. I won't know ahead of time what tmux session:window.pane I want to send these keys to, but I don't want to have to type out that whole thing. The first time I press Enter I want it to all pop up ready for me to just move over to the right stuff, set my session, window, and pane, and just hit enter.

但是我想要所有的 (除了第一个)就像我输入 。我不会提前知道tmux会话:窗口。我想把这些键发送出去,但是我不想把所有的都打印出来。第一次按回车键时,我想让所有的弹出窗口都准备好,让我移动到正确的东西上,设置我的会话、窗口和窗格,然后按回车键。

But right now it's treating the others as command characters. What do I need to do here?

但是现在,它把其他人当做命令角色。我在这里需要做什么?

2 个解决方案

#1


0  

You should use <lt> to replace the first < in each of the keys. So the command would be

您应该使用 来替换每个键中的第一个<。所以命令是。

nnoremap <cr> :nnoremap <lt>cr>:!tmux send-keys -t :1.0 "py.test --cov" C-m <lt>cr><lt>cr>

#2


0  

One (likely) horrible solution is

一个(可能)可怕的解决方案是。

c<left><<right><right>r>

#1


0  

You should use <lt> to replace the first < in each of the keys. So the command would be

您应该使用 来替换每个键中的第一个<。所以命令是。

nnoremap <cr> :nnoremap <lt>cr>:!tmux send-keys -t :1.0 "py.test --cov" C-m <lt>cr><lt>cr>

#2


0  

One (likely) horrible solution is

一个(可能)可怕的解决方案是。

c<left><<right><right>r>