Hacker News new | ask | show | jobs
by graywh 4810 days ago
Only problem with those imaps is that now you can't type ì, ë, ê, or è. Vim is pretty dumb about utf-8.

I'd also suggest using <C-o> instead of the <Esc>...i dance.

Edit: "The way [Vim] stores alt+letter in its input queue collides with UTF-8/Unicode handling" -- LeoNerd in freenode/#vim at 2013-04-15 15:22:29

3 comments

I think I solved that problem quite elegantly :) However I still have a small TODO regarding printing from cygwin:

    set encoding=utf-8
    " TODO check if printing of utf-8 chars works with 'set fileencoding=utf-8'
    set fileencoding=utf-8


    " {{{ Diacritic characters: <Leader>char (keyboard switching doesn't work in cygwin)
    " Use the same keys as on a keyboard
    inoremap <Leader>; ö
    inoremap <Leader>: ö
    inoremap <Leader>' ä
    inoremap <Leader>" Ä
    inoremap <Leader>[ ü
    inoremap <Leader>{ Ü
    inoremap <Leader>- ß

    " Comment/Uncoment following as you need:
    "inoremap <Leader>`A Á
    "inoremap <Leader>`Ae Ä
    "inoremap <Leader>`C Č
    "inoremap <Leader>`D Ď
    "inoremap <Leader>`E É
    "inoremap <Leader>`I Í
    "inoremap <Leader>`Ll Ĺ
    "inoremap <Leader>`L Ľ
    "inoremap <Leader>`N Ň
    "inoremap <Leader>`O Ó
    "inoremap <Leader>`Ou Ô
    "inoremap <Leader>`R Ŕ
    "inoremap <Leader>`S Š
    "inoremap <Leader>`T Ť
    "inoremap <Leader>`U Ú
    "inoremap <Leader>`Y Ý
    "inoremap <Leader>`Z Ž
    "inoremap <Leader>`a á
    ""inoremap <Leader>` ä " defined already
    "inoremap <Leader>`c č
    "inoremap <Leader>`z ž
    "inoremap <Leader>`e é
    "inoremap <Leader>`i í
    "inoremap <Leader>`l ľ
    "inoremap <Leader>`n ň
    "inoremap <Leader>`o ó
    "inoremap <Leader>`ou ô
    "inoremap <Leader>`r ŕ
    "inoremap <Leader>`s š
    "inoremap <Leader>`t ť
    "inoremap <Leader>`u ú
    "inoremap <Leader>`y ý
    "inoremap <Leader>`z ž
    " }}}
"Vim is pretty dumb about utf-8."

It might not work the way you prefer using your favorite input method, but vim allows you to enter any utf-8 character, and even has mnemonic digraphs for many you are most likely to want. To get è, for example, in input mode just type <ctl>-k`e.

Using the digraph will get around the insert-mode alt-key maps.
or `, delete, e if digraphs are activated (IIRC)
I code on a Macbook, and I actually use say... Option+i, e in order to get ê. That works inside Vim, too, I just found out.

Obviously not very helpful to people not on a Mac, but I don't have to go through Alt mappings at all.

The point of my comment is that with an imap on <a-j>, you can't input the character ê because it will trigger the mapping. This includes option+i, e on OS X.