I want cursor to be in the last character of first line, in INSERT mode when I open a file in vim.

It should work in all cases::

  1. Open file from CLI, like, $ vim fileName
  2. Open file from inside vim, like :e fileName
  3. Open file from inside vim in new window, like :split fileName

try adding this to your .vimrc

autocmd BufReadPost *  startinsert!

From :h usr_40.3

The general form of the :autocmd command is as follows: >

:autocmd [group] {events} {file_pattern} [nested] {command}

From - http://vimdoc.sourceforge.net/htmldoc/insert.html#:startinsert

Start Insert mode just after executing this command.
Works like typing "i" in Normal mode. When the ! is included it works like "A", append to the line. Otherwise insertion starts at the cursor position.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.