How do you go to a line beginning or end and enter insert mode in vim?
For example you can delete a line number 33 with :33d
. Is there an equivalent that lets you perform the same action as 36G
followed by i
or 36G
, A
so that you can go to line 36 and insert at the start of the line or the end of the line with a single command?
You can use :help :startinsert
for that:
:33|star " go to line 33 and start insert mode before the cursor (like i)
:33|star! " go to line 33 and start insert mode after the end of the line (like A)
Note that :startinsert
doesn't accept a range so we must use :help :|
as a workaround.
Also, :startinsert
does i
and A
but it doesn't do I
or a
. I don't know of any easy workaround. If you feel adventurous, :help feedkeys()
could help you craft your own custom commands:
:33|call feedkeys('I')