This behaviour seems a bit strange (
^ is the cursor):
inoreabbrev @@t <esc>0 what@@t what ^
inoreabbrev @@t <esc>0h what@@t what ^
0 is not enough to put the cursor at the beginning of the line after abbreviation?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
Why using 0 is not enough to put the cursor at the beginning of the line after abbreviation?
When you press space, Vim expands
<esc>0, then the space command is executed. In insert mode, the space command inserts a space, but in normal mode it moves the cursor 1 character forward (see
To prevent the space from interfering, you can consume it with
inorea <silent> @@t <esc>0@=<sid>eat_space()<cr> fu s:eat_space() abort let c = nr2char(getchar(0)) return c =~# '\s' ? '' : c endfu