10

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?

muru
  • 24,838
  • 8
  • 82
  • 143
Giorgio Robino
  • 2,044
  • 2
  • 17
  • 30

1 Answers1

11

From :help 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 :help '', 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. Muru's suggestion of +- could a good option.

8bittree
  • 1,536
  • 12
  • 20
  • 4
    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 01:42