3

I use abbreviations extensively to make writing in languages other than English easier. For example, I have something like this set up for when I'm writing in Italian:

inoreabbrev perche' perché
inoreabbrev dopodiche' dopodiché

This way I can type the words above quickly without changing keyboard layout system-wide or using digraphs. Sadly these abbreviations don't work when the word is capitalized, like when it comes after a period.

Is there a way to way to force an abbreviation to trigger regardless of the case? Do I have to set up 2 abbreviations for every word or is there another way, like regexes or a special option?

  • I always thought that it would be good to use autocomplete for that. – user1685095 Apr 27 '17 at 19:06
5

You could use the abolish plugin. For your example you could use the following:

:Abolish perche{'} perché

It changes perche' to perché, Perche' to Perché and PERCHE' to PERCHÉ. For the second example:

:Abolish dopodiche{'} dopodiché
  • Ah, Tim Pope. If he's wrote a plugin for this, there's definitely no better option. Looks like I'll have one more of his plugins in my bundle folder then. Thank you very much sir. – zool Apr 26 '17 at 14:36
  • 1
    I have created a vim-abolish substitution file for every accented word in Italian, should someone need it: gist.github.com/mrzool/f796b0b55b5783528915ac4f66095156 – zool May 2 '17 at 8:36
0

I would have written an imap-<expr> on ' that tests the previous character, e and E would become é and É. And so on.

The caveat being when writing source code where ' is a valid character on its own, and where we could have a single-quote after an e. We could check the current syntax in that case.

function! s:compose_if_match(accent, letters)
  let crt = getline('.')[col('.')-2]
  if crt =~? a:letters
    return "\<bs>\<c-k>".a:accent.crt
  else
    return a:accent
  endif
endfunction

inoremap <expr> ' <sid>compose_if_match("'", 'e')
inoremap <expr> ` <sid>compose_if_match("`", '[aeu]')

Honnestly, unless I don't have a French keyboard, instead of retro-actively fixing words automagically thanks to quotes and backticks, I'd rather hit backspace and fix the word by hitting the proper key which is also on the first row. I would understand that using CTRL+K on non-French keyboards is tiresome.

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.