7

I usually use Vim with an Italian keyboard (I'm from Italy), (mainly in an Ubuntu Linux Virtualbox guest from a Windows host).

I have problems when I have to enter some frequently used characters (in Unix) not present in Italian keyboard layout, I'm referring especially to these chars:

  • tilde: ~ (home directory alias)
  • back quote / back tick: ` (mainly in ruby programs)

Ok, I can use $HOME instead of ~, but there is any Vim specific way (maybe some keystroke sequence) to enter these (and other) "special" chars non present in keyboard available?

Solution could be a key-binding in .vimrc? By example I have in my .vimrc this:

map ' `

but as you can imagine I'm unhappy with this specific key remap...( and I have <Fx> already occupied)

BTW, Maybe the question is a bit off-topic because it is not related to Vim directly, but to the keyboard hw/ language setting; maybe ask in Stack Overflow is better?

  • How many keystrokes are you willing to dedicate? Since you're using Ubuntu, you can always use Unicode: Ctrl-Shift-u, then 7E will give you ~, Ctrl-Shift-u, then 60 will give you `. – muru Sep 25 '15 at 8:48
  • thx, but It seems not working. plese note I use an headless ubuntu through a remote terminal (putty)... – Giorgio Robino Sep 25 '15 at 9:56
  • 2
    Try from insert mode: Ctrl-v u 007e – VanLaser Sep 25 '15 at 10:12
  • 2
    That can be expedited by looking at man ascii on Ubuntu. – muru Sep 25 '15 at 10:25
  • 1
    @GiorgioRobino - what happens if you hit AltGr ^ and AltGr ' combos ? Reference: superuser.com/a/667654/292962 – VanLaser Sep 25 '15 at 10:30
7

From :he digraph:

Digraphs are used to enter characters that normally cannot be entered by an ordinary keyboard.

Running :digraphs will show you the currently defined digraphs. ` is defined as '! and ~ is defined as '?.

There are two ways of entering digraphs:

<C-k> {char1} {char2}
{char1} <BS> {char2}

The second method requires :set digraph.


That said, inoremap '' ` might be quicker, assuming you don't often need two 's in a row. Note that globally remapping '' will mask :he '', but mapping it in insert and command modes is safe to my knowledge. Off the top of my head, I can't think a similar memorable and convenient alternative for ~. -- and == seem likely to be used as themselves frequently.

  • 2
    Ooh! +- for tilde! In some contexts, a tilde indicates approximate information, and one could imagine +- as having a similar meaning. – muru Sep 26 '15 at 1:42

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.