I frequently run into the situation that I have to press space to "actuate" the command I entered, e.g. after I hit ~ to swap case of a letter.

Why is that?

  • 2
    Do you have a mapping beginning with ~? – muru Nov 12 '15 at 17:52
  • 1
    Are you using vim though ssh? ~ is the start of an SSH escape sequence, so it waits to see the next character before passing it through. – DopeGhoti Nov 12 '15 at 18:14
  • I don't have any mapping at all with ~, and I'm not using it via SSH. – lindhe Nov 12 '15 at 19:06
  • Does it work when you press ~ twice? It should also move the cursor to the next character right. – ott-- Nov 12 '15 at 20:07
  • Yes it does work when pressing ~ twice. – lindhe Nov 12 '15 at 21:09

muru and others are looking at this in terms of the programmability and configurability of vim itself; other comment-answerers are looking at SSH. But there is a third, quite different, answer.

  • You have a keyboard layout that supports dead keys.
  • In your layout, ~ is such a dead key, possibly mapped to the conventional U+0303 "combining tilde" (  ̃).
  • Your layout employs the usual convention, enshrined in ISO/IEC 9995-3 and ISO/IEC 9995-11, that a combining-character dead key followed by Space results in an equivalent non-combining, spacing, character.

So pressing ~Space is how you get a simple U+007E "tilde" (~) character in your terminal emulator; and hence how you actually effect the vim command. The ~ keypress on its own isn't sending characters through your terminal at all, because the terminal emulator is waiting to see what is pressed next after the combining "dead" key. As far as vim is concerned, nothing has actually happened yet, at that point.

If this is the case you can demonstrate it to yourself by entering insert mode and then pressing something else after the ~. What you press will of course depend from your chosen keyboard layout. Commonly, ~a will combine to ã in such layouts.

A little-known standards-ism

The "common secondary group" defined by ISO/IEC 9995-3:2010 is intended to be invariant across different national layouts. The U+0303 "combining tilde" character has a standard place in the secondary group.

Therefore: On a keyboard layout that conforms to ISO/IEC 9995-3:2010 one should be able to get combining tilde with the same sequence of keys irrespective of the primary group layout.

  • These keys are ⯖ Group2D12, expressed in standardese. is a Unicode glyph proposed for the engraving of "Group 2 Select" keys. Most current documentation uses , for reasons that are obvious if your WWW browser is showing a blank keytop in the preceding sentence. ☺
  • In terms of the actual engravings that one might see on the keytops this will be something like Shift+AltGr] (PC-style U.S.-layout) or Shift+⌥ Option] (Mac-style). These are two separate chords, note. The single chord Shift+AltGr+] is something else.

Which means in particular, here: If you switch to a layout where ~ is not a dead key, which is probably what you are just about to do, as long as the keyboard layout supports the ISO/IEC "common secondary group" you still have access to the dead key should you need it.

Your terminal emulator and keyboard layout most likely don't support this, as concrete implementations are quite rare at the time of writing. But this is what the ISO keyboard standards people have been pushing for for the past few years.

  • This seems to be the case. I forgot that this is "always" the case, not only in Vim. It's hard to think of the commands as characters when you think it in Vim movements, verbs, nouns etc. :) Thank you. – lindhe Nov 12 '15 at 21:12
  • I'd upvote this twice if i could for a thorough, knowledgeable, and informative answer. – cas Nov 12 '15 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.