问题描述
终端是否可以检测到 + 或 + 按键?
Is it possible for the terminal to detect + or + keypresses?
我正在尝试将 vim 配置为使用这些序列进行键映射,虽然它们在 gvim 中工作正常,但它们似乎在任何终端控制台中都不起作用.
I am trying to configure vim to do key mappings that use these sequences, and while they work fine in gvim, they don't seem to work in any terminal console.
奇怪的是,虽然在vim中没有检测到+,但是将映射到 正确映射,但随后按 + 的行为类似于 !
The curious thing is that although + is not detected in vim, mapping to maps properly, but then pressing + behaves like !
推荐答案
当按下<C-Enter>
时,某些终端会发送.这相当于发送
<C-J>
.
Some terminals send <NL>
when <C-Enter>
is pressed. This is equivalent to sending <C-J>
.
了解终端对 <Shift-Enter>
、<Ctrl-Enter>
和 <Enter>
的作用,进入你的终端,输入 <Ctrl-V>
(类似于 sykora 对 vim 的建议),然后输入你感兴趣的序列.
To find out what your terminal does with <Shift-Enter>
, <Ctrl-Enter>
and <Enter>
, go to your terminal, type <Ctrl-V>
(similar to sykora's suggestion for vim), and type in the sequence you're interested in.
使用 gnome-terminal,我得到以下信息:
Using gnome-terminal, I get the following:
<Enter> : ^M
<S-Enter> : ^M
<C-Enter> : <NL>
查看man ascii
表示^M
给出<CR>
序列.
答案是取决于终端,有一个简单的方法来检查.
The answer is that it depends on the terminal, and there's an easy way to check.
这篇关于终端能否检测到<Shift-Enter>还是<Control-Enter>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!