1

How do I make ae in evil insert mode produce æ? This would be the equivalent of inoremap ae æ in vim. (I tried (define-key evil-insert-state-map (kbd "ae") (kbd "\C-kae")), but after this typing a (without an e after it) didn't produce an a, but rather the error a is undefined.)

4
  • 1
    Not a very clear question, IMO. Why don't you describe ("specify") just what you are trying to do and just what you tried and just what you saw from your trial and just what you expected to see instead?
    – Drew
    Jul 12, 2016 at 22:01
  • Maybe (define-key evil-insert-state-map (kbd "ae") "æ")?
    – npostavs
    Jul 13, 2016 at 12:55
  • @npostavs, no, that stills ruins the bare "a".
    – Toothrot
    Jul 13, 2016 at 16:33
  • This is probably more of a job for abbrev-mode than for a function. See, for example, emacs.stackexchange.com/questions/7435/….
    – Dan
    Jul 13, 2016 at 18:08

2 Answers 2

2

You could try something like

(add-hook 'post-self-insert-hook
          (lambda ()
            (and (eq last-command-event ?e)
                 (looking-back "ae" (- (point) 2))
                 (replace-match "æ"))))
2
  • Thanks! there is no timeout on this. how would I escape to produce 'ae'?
    – Toothrot
    Jul 28, 2016 at 18:34
  • You can use a C-q e.
    – Stefan
    Jul 28, 2016 at 19:18
2

have a look at the key-chord emacs package. it allows you to define mappings of multiple keys and take action on them. in your case the action would just be (insert "æ").

alternatively, insert a digraph by typing C-k a e in evil's insert mode. this invokes (evil-insert-digraph) and reads a and e, then produces æ.

2
  • C-k doesn't give me any digraph here. Could you explain what you mean? Is that part of the key-chord package.
    – Stefan
    Jul 28, 2016 at 19:23
  • part of evil, works only in insert state Jul 29, 2016 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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