终端能否检测到< Shift-Enter>或< Control-Enter> ;? [英] Can terminals detect <Shift-Enter> or <Control-Enter>?
问题描述
终端是否可以检测⇧Shift + Enter↵或 Ctrl + Enter↵按键?
Is it possible for the terminal to detect ⇧ Shift+Enter↵ or Ctrl+Enter↵ 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中未检测到 Ctrl + Enter↵,但映射了 Enter↵到 Esc 正确映射,但是按 Ctrl + Enter↵的行为类似于Enter↵ !
The curious thing is that although Ctrl+Enter↵ is not detected in vim, mapping Enter↵ to Esc maps properly, but then pressing Ctrl+Enter↵ behaves like Enter↵!
推荐答案
某些终端在<$ c时发送< NL>
$ c>< 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> ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!