# Triggering automatic replacements of certain strings

I am using the Vim version 8.0 editor, mostly via GVim. I would like to be able to type unicode/greek characters like lambda, mu, alpha inside my Haskell scripts.

There is a vim plugin called latex-unicoder which is almost what I want. The disadvantage of the plugin is that I need to repeatedly go into Normal mode, press Ctrl-L insert the latex symbol for the character and then manually go back into insert mode.

This is quite tedious. Emacs has something called M-x set-input-method [RET] tex which automatically and immediately replaces the occurences of \lambda, \alpha by their corresponding Greek characters.

Since I intend to use only a handful of greek characters, I am willing to manually create such a dictionary of Greek characters for automatic insertion when their latex name is written.

How should I go about doing this?

• I've never used latex-unicoder so this might not work but if the ctrl-l mapping of this plugin is what you want excepted that it makes you quit insert mode, maybe you can try an insert mode mapping? Something like this imap <C-l> <Esc><C-l> or something more complexe which will make you go back to insert mode too. Jul 25, 2017 at 6:58

you can do something like :iab \mu µ

Note however that this requires :set isk+=\ which may not always be desirable.

Another approach is :imap \mu µ . But this has the drawback that things starting with \ will not show up until entered completely

• Use showcmd option to see a mapping as you type it in, at the right end of the last line. Read :help 'showcmd' for more information. Jul 26, 2017 at 8:36

This doesn't answer your question directly, but you can use digraphs to enter Greek characters and many others in insert mode by pressing Ctrlk followed by a two character code (see :h digraphs).

For example, lambda, mu and alpha would be l*, m* and a*.

If you'd like to use snippets, snipmate allows you to define your own snippets. Another popular plugin is UltiSnips, which also describes how to add your own snippets.

• I use a script to define a "French" mode where certain digraphs don't require the <C-k>. This could easily be done for greek letters, too. Alternately, enabling/disabling a set of abbreviations for the longer sequences like \mu Aug 2, 2021 at 14:10