In vim, if I execute the following from the command line
:normal! i
vim does not enter insert mode. Likewise the command
:normal! A
will move the cursor to the end of the line, but the cursor remains in insert mode.
Any ideas why this doesn’t work? Failing that I would like to know an alternative way to enter insert mode from the body of a vimscript function (and have insert mode persist after the function returns of course).
Edit: Looks like :startinsert will fullfill the second part of the question, but I’m still wondering how I can do something like :normal! A or :normal! a and why those don’t simply work as expected. Simulating “append” with arrow movements is a bad solution, because of things like empty lines and such.
The normal command considers ending in insert mode as an incomplete command and aborts. From
help normal::startinsertmight be the command you are looking for.:normal Acan be achieved by appending a bang (!) tostartinsert, as suggested by Ingo Karkat. Fromhelp startinsert: