I've noticed while editing along a line in a .txt file in insert mode the cursor will move to the start of the line following a write using key sequence:<esc>:wI'd like to change this behavior such that the cursor will stay in position following a :write. Is this possible? I don't need the cursor to remain in insert mode, I'd just like it to maintain its last position following a write.I am using gVim 7.4 on windows. My .vimrc is very basic, I don't believe any of my settings interfere with this behavior. I have also removed sourcing of mswin.vim and example.vim from my .vimrc (as bundled with the official vim.org windows installer).After reading the comments below I looked at the issue again and realized the cursor only slides to the far left after a write on lines which are entirely made up of trailing white space. In other words, the cursor only slides to the far left upon esc-:w when the line is a hanging indent with no other characters besides spaces. The .vimrc is handling indent behaviors with these settings: set tabstop=4set softtabstop=4set shiftwidth=4set expandtabset autoindent So, a new line created below an indented line will contain 4 trailing white spaces as the first 4 spaces of the line (which I want to keep). Upon the 'esc' key press the cursor slides to the far left of the buffer. Is there a way to retain cursor position upon hitting 'esc' to return to normal mode, on a line made up of trailing white spaces (as indentation)?
Why does the cursor move to the start of the line after ?
cursor movement;save
Looking at the documentation for autoindent has an answer as to why and how to work around it. :help 'autoindent':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'.In other words, if you want it to not lose the indent, type something and then backspace it before hitting Esc, and the leading space will remain.Alternatively, if you just want to be back at the indent-level when you go back into insert mode and are using 'cindent' as well, use Shift-S instead of i, which will clear the (already empty) line, and start at the appropriate indentation level. This is not as general a solution as the one above, but I prefer this when I'm writing C code, so that my files don't actually get saved with white-space only lines.