On Mon, Nov 8, 2021 at 7:46 PM '[email protected]' via vim_dev <[email protected]> wrote: > > After adding a line with "o" (on an indented line with "autoindent" on) then > (while being in INSERT mode) using "^O" to enter a NORMAL mode command the > cursor jumps back to the beginning of the line (erasing the indent), and will > not return to the starting position after immediately pressing ESC (i.e. > "o^O<ESC>"). > This behavior is not observed, if - indenting to the same cursor position - > the same keys are pressed (i.e. "<white_space>+^O<ESC>"). In this case the > cursor's position is unchanged. > > Is this behavior intended? > > Intended or not, it makes writing code difficult, as you have to know how you > got here ("o" vs. indenting) i.e. the behavior is different. > > mode() shows "i" in both cases.
IIUC what is said under ":help 'autoindent'", this behaviour is intended, as follows: > *'autoindent'* *'ai'* *'noautoindent'* *'noai'* > 'autoindent' 'ai' boolean (default off) > local to buffer > Copy indent from current line when starting a new line (typing <CR> > in Insert mode or when using the "o" or "O" command). If you do not > type anything on the new line except <BS> or CTRL-D and then type > <Esc>, CTRL-O or <CR>, the indent is deleted again. Moving the cursor > to another line has the same effect, unless the 'I' flag is included > in 'cpoptions'. > When autoindent is on, formatting (with the "gq" command or when you > reach 'textwidth' in Insert mode) uses the indentation of the first > line. > When 'smartindent' or 'cindent' is on the indent is changed in > a different way. > The 'autoindent' option is reset when the 'paste' option is set and > restored when 'paste' is reset. "If you do not type anything on the new line […] and then type <Esc>, CTRL-O or <CR>, the indent is deleted again." Best regards, Tony. On Mon, Nov 8, 2021 at 7:46 PM '[email protected]' via vim_dev <[email protected]> wrote: > > After adding a line with "o" (on an indented line with "autoindent" on) then > (while being in INSERT mode) using "^O" to enter a NORMAL mode command the > cursor jumps back to the beginning of the line (erasing the indent), and will > not return to the starting position after immediately pressing ESC (i.e. > "o^O<ESC>"). > This behavior is not observed, if - indenting to the same cursor position - > the same keys are pressed (i.e. "<white_space>+^O<ESC>"). In this case the > cursor's position is unchanged. > > Is this behavior intended? > > Intended or not, it makes writing code difficult, as you have to know how you > got here ("o" vs. indenting) i.e. the behavior is different. > > mode() shows "i" in both cases. > > -- > -- > You received this message from the "vim_dev" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups > "vim_dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vim_dev/d4c174ad-3dcb-4dbc-9cc9-a1d5583c7e02n%40googlegroups.com. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAJkCKXsYJJmp69s%3DtEFY3Z9U48Hmb%3D450nUg15fqatpgyML5KQ%40mail.gmail.com.
