I would like to trigger a multi line abbreviation in Vim, without entering the 'trigger' character, and with the cursor ending in insert mode at a particular location.
I am nearly there, but just failing to make it.
Thus far, i have added the following to my _vimrc:
" eat characters after abbreviation
function! Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunction
iabbr <silent> if if ()<left><C-R>=Eatchar('\s')<CR>
:iabbr <silent> rfF <- function( )<CR>{<CR> <CR>}<Esc>3k$h<Insert><c-r>=Eatchar('\m\s<bar>/')<cr>
Which is mostly successful, in that it yields the following when i type rfF Ctr-]
to trigger the abbreviation's expansion:
<- function( )
{
}
However, the outcome varies depending on how i trigger the abbreviation.
If i trigger with a <space>
the space between the brackets expands:
<- function( )
{
}
... and if i <CR>
:
<- function(
)
{
}
I recently asked, and had answered, a question about preventing the characters that trigger an abbreviation from being added in the single line case.
Is this possible with multi-line abbreviations?