1
set scrollopt+=hor
set scrollopt-=ver
set nowrap
set mouse=a
2split
windo set scrollbind
set statusline=%F%m%r%h%w[%{&ff}]%y%p%%\ %04l\/%04L\ Oc:Hx\ %b:%B%=%qF[%n]%t

Above .vimrc is working quite well for me but I'd like to start already in that second (main split) ready to scroll with mouse etc rather than having to click into it from the first split - which is intended to work as a header...
Really surprised I have not managed to find this anywhere yet!

I am issuing vim file_to_inspect to start Vim.

If it is not possible to be directly in split 2 by .vimrc but the command line can do it that would be second best, then a fix up in my shell would allow:

vim -{some opts} file_to_inspect

(My second day of looking into vim, getting a bit polished in a few places but lots of rooms to explore.)

Things tried:

:wincmd k (&j)
within vim typing the command :wincmd j & then wincmd k DO toggle me between splits in the same way that <C-w> j & k do.

Line placed in .vimrc I arrive in 1st split (the header) either (j or k variant) line at the end of .vimcr made no difference in either case. Here is the file I tried with j as last char (I tried k too).

:set scrollopt+=hor
:set scrollopt-=ver
:set nowrap
:set mouse=a
:2split
:windo set scrollbind
:set statusline=%F%m%r%h%w[%{&ff}]%y%p%%\ %04l\/%04L\ Oc:Hx\ %b:%B%=%qF[%n]%t
:wincmd j

Tried autocmd VimEnter * winced j and that is what I needed.
@Tumbler41 Thanks! If you'd like to make an answer I can accept it.
(NO idea why the rather obvious winced did not work - my first noob stab at that yesterday was to try and enter the ctrl-w command somehow directly in .vimrc)

4
  • 1
    Have you read :h :wincmd? Does adding wincmd k solves your problem?
    – statox
    Jun 2, 2016 at 12:03
  • I tried with wincmd (stackoverflow.com/questions/8822237/…) but it doesn't seem to work upon starting vim. Maybe an autocmd is needed there ? I can't find it so far...
    – Feffe
    Jun 2, 2016 at 12:07
  • 2
    No autocmd is needed: it does work for me. How did you include wincmd to your .vimrc? (Edit your question to show what you tried please)
    – statox
    Jun 2, 2016 at 12:14
  • I can reproduce it. If I start vim it doesn't work, but if I source the file it works fine. (Using gVim 7.4) Tried using an autocmd autocmd VimEnter * wincmd j. That works. Not sure why it wouldn't work straight from vimrc though.
    – Tumbler41
    Jun 2, 2016 at 15:09

1 Answer 1

2

One method is using an autocmd when vim enters:

autocmd VimEnter * wincmd j

The only reason I can think why this would work better than just putting wincmd j is perhaps it delays the command by a bit and lets the 2split take full effect maybe?

(If @statox could tell us how he got his to work I'd be grateful.)

Your Answer

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

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