When I switch buffer and then go back to it(basically when I get back to any buffer that was previously opened), cursor is placed at the start of the line, loosing previous position in line. This is very annoying.
Vim cursor jumps to beginning of the line after buffer switch
You can use the setting
:se nostartofline
or short:
:se nosol
Documentation:
*'startofline'* *'sol'* *'nostartofline'* *'nosol'*
'startofline' 'sol' boolean (default on)`
global
{not in Vi}
When "on" the commands listed below move the cursor to the first
non-blank of the line. When off the cursor is kept in the same column
(if possible). This applies to the commands: CTRL-D, CTRL-U, CTRL-B,
CTRL-F, "G", "H", "M", "L", gg, and to the commands "d", "<<" and ">>"
with a linewise operator, with "%" with a count and to buffer changing
commands (CTRL-^, :bnext, :bNext, etc.). Also for an Ex command that
only has a line number, e.g., ":25" or ":+".
In case of buffer changing commands the cursor is placed at the column
where it was the last time the buffer was edited.
NOTE: This option is set when 'compatible' is set.
Whenever I save a buffer, the cursor jumps to the start of the buffer, this answer also solved the problem I encountered. Thanks. –
Eulalia
I had to disable autosave on insert mode. It was autosaving while in insert mode, which caused the cursor to jump to the beginning:
Add
let g:auto_save_in_insert_mode = 0 " do not save while in insert mode
to your .vimrc
.
Documentation: https://github.com/vim-scripts/vim-auto-save.
© 2022 - 2024 — McMap. All rights reserved.