I'd like to add a semicolon automatically in my current line. So I have this in my
function Test() if matchstr(getline(line('.')), ';') != ';' && strlen(getline(line('.'))) > 4 call setline(line('.'), substitute(getline(line('.')), '$', ';', 'e')) "execute 's/;\?$/;/e' endif endfunction autocmd TextChangedI <buffer> call Test()
To sum it up, what this function does:
- Look, if there's already a semicolon (currently doesn't matter at which position it is)
- Look if the current line has more than 4 characters
- It both conditions are true, add a semicolon to the line
ihu is my abbreviation for
unsigned short (i stands for integer):
iab <buffer> ihu unsigned short
Now as you can see the abbreviation works in the beginning but after the placement of the semicolon my abbreviations don't work anymore.
You can also see in the function that I've tried to use
but this produces the same problem.
Do you have an idea how I can add the semicolon without breaking my abbreviations (and tabstops of some snippet-plugins)?
Ok, I found out that if it sets the semicolon earlier than after 4 characters, than I'll be able to use my abbreviations as usually. But I'd be happy if someone knows an answer to that question.