Skip to main content
1 of 3
filbranden
  • 29.9k
  • 5
  • 28
  • 73

You can accomplish what you're trying to do by using an expression (introduced using <C-r>=) and then matching a single "a" word at the end of the text that precedes the word being abbreviated.

When you find that "a" word, then you can expand it to a <C-w>, that will delete that word, followed by the abbreviation you desire.

This command-line does what you want for "àquilo":

:iab aquilo <C-r>=match(getline('.')[0:col('.')-2], '\<lt>a $') >= 0 ? "\<lt>C-w>àquilo" : 'aquilo'<CR>

But it's pretty awkward. TODO: Let me replace that with a function, which will make it cleaner.

filbranden
  • 29.9k
  • 5
  • 28
  • 73