Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
647 views
in Technique[技术] by (71.8m points)

vim - Can terminals detect <Shift-Enter> or <Control-Enter>?

Is it possible for the terminal to detect ? Shift+Enter? or Ctrl+Enter? keypresses?

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.

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?!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Some terminals send <NL> when <C-Enter> is pressed. This is equivalent to sending <C-J>.

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.

Using gnome-terminal, I get the following:

  <Enter> : ^M
<S-Enter> : ^M
<C-Enter> : <NL>

Looking at man ascii indicates that ^M gives the <CR> sequence.

The answer is that it depends on the terminal, and there's an easy way to check.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...