Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep the cursor column while swapping buffers in vim

Tags:

vim

In vim, if you swap buffers with :bn and :bp, the cursor stays on the same line, but not on the same column. Is there a way to keep it on the same column as well ?

like image 590
Stefano Borini Avatar asked Aug 02 '09 18:08

Stefano Borini


2 Answers

:set nostartofline

from the help: "In case of buffer changing commands the cursor is placed at the column where it was the last time the buffer was edited."

like image 92
rpilkey Avatar answered Nov 15 '22 11:11

rpilkey


Off the top of my head I don't think so. But Vim sets the mark " as the last position when exiting a buffer. So typing `" will get you back to that spot. You could try creating an auto-command to jump to that mark automatically on entering a buffer. Try something like

:au BufEnter  * :normal `"
like image 24
Steve K Avatar answered Nov 15 '22 10:11

Steve K