2

Some of the key inputs on my nvim running in xterm are a bit odd. For example, to get the '^' key, I have to press shift-6, and instead of it just generating a '^' character, it actually generates '<S-^>'. The rest of the symbols on the number keys (ie, !, ", £, $, ....) just generate what one would expect; ie, '!', '"', '£', '$' etc. I have the same issue with a few other symbol keys that are not on the number row.

I've not had this issue before, using terminals other than xterm, so to get around this, I have had to modify some of my vim function mappings accordingly. Annoying but it seems to work.

However, I have a function that calls getcharstr() and this is causing some problems. In the case of the '^' character, getcharstr() actually returns the sequence '<80><fc>^B^' (where '^B' is, I think, ctrl-B, and the trailing ^ is the literal '^' character). I know that getcharstr() returns 128 for the first byte of an 'encoded' character. This explains the <80>. But I'm at a loss regarding the <fc>^B bit

My question is, how do I test this string against '<S-^>' (or preferably, just '^')? Clearly, as it stands, it doesn't match and I'm unsure of a general way I can/should pre-process the input string before comparing it. Another sequence that causes me problems is <M->>. This presents itself to nvim (running in xterm) as <M-S->>, and getcharstr() returns the sequence '<80><fc>*>' (where '*' is a 'newline' character - ASCII 10 - eh??)

Alternatively, and this would make life much easier, is there any way of setting xterm or vim/nvim to generate more sensible characters - ie, just '^' instead of '<S-^>'? (I'm still interested in how to tackle this from within vim though, even if xterm can be 'fixed')

5
  • Neovim and Vim or only Neovim? Also, it looks like your xterm is broken so that's what you should fix. Commented Jun 25 at 10:07
  • I'm not able to check vim at the moment on this particular installation. And yes, the problem seems to be with xterm, but I have seen the same issue with xterm on other systems, and I have seen other peoples' posts about <S-^> being generated instead of just ^ (though not necessarily the '^' character), so it's not just me. And if I could work out how to fix xterm, I would Commented Jun 25 at 10:48
  • Solved! I would mark it as solved but I can't see how to do that. In fact I can't see a button to post an answer either, hence this comment. Anyway, it turns out that the usual vim syntax "\<S-^>" actually expands out to '<80><fc>^B^'. All these years using vim and I never knew that! Oh well. Still no idea why xterm is generating <S-^> instead of just ^ though Commented Jun 26 at 14:42
  • You should have a text field similar to the one you used for the question at the bottom of the page. Once you have posted your answer, accept it with the checkmark. Commented Jun 26 at 17:03
  • neovim's using modifyOtherKeys and some of the characters will differ with other terminals because they don't follow xkb as closely. Commented Jun 29 at 13:05

1 Answer 1

0

Short: xterm is providing the shift-modifier, because that's what you pressed, but showing the result of the shift because that was the original implementation, predating "fixterms" by years. xterm does provide a different setting for modifyOtherKeys which separates the two details, but I don't expect a rapid fix from the neovim developers.

TL;DR - XTerm "Other" Modified Keys

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.