I have a question about tabs within vim and I'm using VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 17 2018 20:33:56) Included patches: 1-1255 Compiled by [email protected]

tab bindings:

" This replaces :tabnew which I used to bind to this mapping
nmap <leader>t :enew<cr>
" Move to the next buffer
nmap <leader>l :bnext<CR>
" Move to the previous buffer
nmap <leader>h :bprevious<CR>
" Close the current buffer and move to the previous one
" This replicates the idea of closing a tab
nmap <leader>bq :bp <BAR> bd #<CR>
" Show all open buffers and their status
nmap <leader>bl :ls<CR>

The question I have is, is it possible to prevent the cursor from jumping to the beginning of the line? If I have two different files open and I'm half way on the line, when I switch to " file2" and back to "file", I'll be on the correct line, but at the beginning of the line. This causes me to use either w or w# to get back to where I was.

I don't seem to have this issue if I were to vs "file" and "file2".


1 Answer 1


You need to unset the 'startofline' option:

:set nostartofline

See :help 'startofline'

  • Awesome, it looks like this is set by default. Jan 25, 2018 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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