On 24 August 2016, Richard Merry <
rme...@gmail.com> wrote:
> Hello,
> I often work with multiple windows open in Vim; typically at least
> a vertical split. One issue that I sometime see is my left window
> will also have a Syntastic error window open at the bottom, reporting
> errors as expected. I will then move to the right window to do some
> work there; leaving me with two windows on the left: the main file
> buffer window and the lower Syntastic error windows; and the current
> window with focus on the right. When I now move to the left window
> again, with <C-w> h, focus will be given to the Syntastic error window
> and not the actual window on to the buffer I have open.
>
> I fully recognise this is expected behaviour if for example I move
> down to the Syntastic error window before moving right. The issue is
> that moving left directly into the Syntastic error window has never
> once been my desired behaviour.
I'm not sure I understand why you think this can (or should) be
somehow fixed by syntastic. With <C-w>h the focus moves to the window
that is to the left on the cursor's line. According to the manual:
: CTRL-W h Move cursor to Nth window left of current one. Uses the
: cursor position to select between alternatives.
That is, start near the bottom of your right split and you'll land
on syntastic's error window. Start with the cursor higher up, and
you'll land to your left split. This is basic window navigation that
has nothing to do with syntastic.
> One solution would be to have the Syntastic error window close
> automatically upon moving away from the window that it is reporting
> on. Is there anyway to do this out of the box or will I have to get my
> VimL on?
You could try to run lclose (or perhaps SyntasticReset) from a
WinLeave autocmd. But you'd have to be careful not to do that when
you're leaving syntastic's error window, otherwise you wou;dn't be able
to keep the error window open. It isn't trivial, and it's even less
trivial keeping it from breaking other things. Window handling in Vim
is insanely fragile, and the API is less than helpful.
/lcd