Contact Us

Gvim on windows: solving Tagbar’s “window flashing” problem using Vim-Shell

Reading Time: 2 min

Tags:  Vim

One of the annoying things about using Gvim on windows is that every time a plugin calls Vim’s system command, the DOS command window will flash. Tagbar is one of the many plugins which have this problem. Here is a solution for this in Tagbar using Xolox’s Vim-Shell plugin. Please note that I am not referring to Shougo’s plugin with the same name.

Simple Workaround

Before coming to the actual solution, here is a simple workaround. Vim-Shell allows you to use Vim in fullscreen mode, just press F11 to do this. When Vim is in fullscreen mode the flashing command window will not be visible. This workaround has the advantage that it works with other plugins, like Syntastic and Ale as well.

Solution

The second option is to edit tagbar.vim file of the Tagbar plugin and replace Vim’s system command with Vim-Shell’s xolox#misc#os#exec function. The exec function does not show the command window. Please note that, while this change has been working for me for a few months now, the possibility of it breaking something cannot be ruled out.

Here is what you need to do, inside autoload\tagbar.vim file there is a function named s:ExecuteCtags(). Inside this function replace the following line.

1silent let ctags_output = system(a:ctags_cmd)

with these lines.

1let ctags_output_dict = xolox#misc#os#exec({'command': a:ctags_cmd, 'async': 0})
2let vimshell_output = join(ctags_output_dict['stdout'],"\n")
3let ctags_output = vimshell_output

Here is the diff for the change

Diff for the change

Do not update Tagbar

After the modification, you will have to make sure that when updating Vim plugins you do not update Tagbar. If you are using Vim-Plug as a plugin manager, this can be easily done by replacing
Plug ‘majutsushi/tagbar’ with something like Plug ‘~/.vim/plugged/tagbar’ in your plugins list; that is you just specify the path to where Tagbar is installed.

Share