Install and use Tagbar on Mac

Aug 28, 2016 Vim 中文版

Tagbar is a tool that can analyse a file and provide an overview of it’s structure. So, it’s very useful for developers who use Vim as a modern IDE. This article is about how to use and install Tagbar on Mac.



Prerequisite

To install plugins for Vim, I usually use Vundle, a handy plugin manager. And I will use it in this tutorial, so you can try to use it. In addition to that, Tagbar is based on Exuberant Ctags. Thus, you should install it before the following steps. To install it via Homebrew:

# Search Ctags
brew search ctags

# Get info of Ctags
brew info ctags

# Install Ctags
brew install ctags


Install Tagbar

Let’s continue to install Tagbar through Vundle. First, open your Vim configuration (/etc/vimrc or ~/.vimrc), then add the plugin name and related settings. For example:

" skip some content ... "

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'

" Add Tagbar here "
Plugin 'majutsushi/tagbar'

call vundle#end()
filetype plugin indent on

" skip some content ... "

" Drop Tagbar settings at the end of the config file "
" Open an overview of current file by using Tagbar, hot key: F8 "
nmap <F8> :TagbarToggle<CR>

After modification to Vim config, let’s install Tagbar by executing the command in Vim:

:PluginInstall

Or, put the command in your terminal:

vim +PluginInstall +qall


Use Tagbar

Here are useful hot keys when you editing in Vim:

F1  # Open the help doc
F8  # Open a new window that shows an overview of the current file




You might also like:




If you have any suggestions, questions or even find some typos, feel free to contact me. Thank you! :)

zeckli.devforgalaxy@gmail.com   © 2015-2019 zeckli, thanks to Jekyll and GitHub.