当我切换缓冲区并返回它时(基本上是当我回到任何先前打开的缓冲区时),光标会被放置在行的开头,失去了之前在行中的位置。这非常令人烦恼。
您可以使用该设置。
:se nostartofline
简而言之:
:se nosol
文档:
*'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.
我必须在插入模式下禁用自动保存。在插入模式下,它会自动保存,导致光标跳到开头:
添加
let g:auto_save_in_insert_mode = 0 " 在插入模式下不保存
到你的.vimrc
。