I am using ctags with vim on linux.

As soon as I press enter on any tag, the focus goes to the source code window and in order to regain focus on taglist window I have to to do :TlistToggle twice (with variable 'Tlist_GainFocus_On_ToggleOpen' set to 1) - which basically closes the taglist window and opens it again with acquired focus.

I am just curious if we can toggle focus between taglist window and source window without closing the taglist window?

2

There are 2 best solutions below

1
On BEST ANSWER
:help window

...gives the chapter on Vim windows, with

:help window-move-cursor

...being the sub-chapter you're looking for:

4. Moving cursor to other windows           *window-move-cursor*

CTRL-W <Down>                   *CTRL-W_<Down>*
CTRL-W CTRL-J                   *CTRL-W_CTRL-J* *CTRL-W_j*
CTRL-W j    Move cursor to Nth window below current one.  Uses the cursor
        position to select between alternatives.

CTRL-W <Up>                 *CTRL-W_<Up>*
CTRL-W CTRL-K                   *CTRL-W_CTRL-K* *CTRL-W_k*
CTRL-W k    Move cursor to Nth window above current one.  Uses the cursor
        position to select between alternatives.

CTRL-W <Left>                   *CTRL-W_<Left>*
CTRL-W CTRL-H                   *CTRL-W_CTRL-H*
CTRL-W <BS>                 *CTRL-W_<BS>* *CTRL-W_h*
CTRL-W h    Move cursor to Nth window left of current one.  Uses the
        cursor position to select between alternatives.

CTRL-W <Right>                  *CTRL-W_<Right>*
CTRL-W CTRL-L                   *CTRL-W_CTRL-L* *CTRL-W_l*
CTRL-W l    Move cursor to Nth window right of current one.  Uses the
        cursor position to select between alternatives.

CTRL-W w                    *CTRL-W_w* *CTRL-W_CTRL-W*
CTRL-W CTRL-W   Without count: move cursor to window below/right of the
        current one.  If there is no window below or right, go to
        top-left window.
        With count: go to Nth window (windows are numbered from
        top-left to bottom-right).  To obtain the window number see
        |bufwinnr()| and |winnr()|.  When N is larger than the number
        of windows go to the last window.

                        *CTRL-W_W*
CTRL-W W    Without count: move cursor to window above/left of current
        one.  If there is no window above or left, go to bottom-right
        window.  With count: go to Nth window, like with CTRL-W w.

CTRL-W t                    *CTRL-W_t* *CTRL-W_CTRL-T*
CTRL-W CTRL-T   Move cursor to top-left window.

CTRL-W b                    *CTRL-W_b* *CTRL-W_CTRL-B*
CTRL-W CTRL-B   Move cursor to bottom-right window.

CTRL-W p                    *CTRL-W_p* *CTRL-W_CTRL-P*
CTRL-W CTRL-P   Go to previous (last accessed) window.

                        *CTRL-W_P* *E441*
CTRL-W P    Go to preview window.  When there is no preview window this is
        an error.
        {not available when compiled without the |+quickfix| feature}

If Visual mode is active and the new window is not for the same buffer, the
Visual mode is ended.  If the window is on the same buffer, the cursor
position is set to keep the same Visual area selected.

                        *:winc* *:wincmd*
These commands can also be executed with ":wincmd":

:[count]winc[md] {arg}
        Like executing CTRL-W [count] {arg}.  Example: >
            :wincmd j
<       Moves to the window below the current one.
        This command is useful when a Normal mode cannot be used (for
        the |CursorHold| autocommand event).  Or when a Normal mode
        command is inconvenient.
        The count can also be a window number.  Example: >
            :exe nr . "wincmd w"
<       This goes to window "nr".

That being said, by enabling mouse support (set mouse=a), you could just left-click where you want your cursor to be (and drag window borders, and...)

0
On

Isn't it the purpose of TlistOpen ?

Otherwise, if the taglist window has a name which can be recognized, you can extract the window number with let b = bufwinnr(the_buffer_name_or_id) and jump to it with exe b.'wincmd w'. You may need to search the right buffer with something like let buf_id = filter(range(1,bufnr('$')), 'v:val =~ "THEPATTERN"'))