惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
L
LangChain Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
IT之家
IT之家
A
About on SuperTechFans
H
Help Net Security

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
How to Use Tagbar in Neovim
2018-09-28 · via jdhao's digital space

If you have a source file with hundreds or thousands of lines of code. How to you see its structure and go to some classes or methods quickly in Nvim? The solution is to use tagbar.

Installation#

To use tagbar, you have to install universal-ctags, which will generate tag files for tagbar to use.

Install universal-ctags#

For Linux#

We need to build and install by ourself:

git clone https://github.com/universal-ctags/ctags.git
cd ctags
./autogen.sh
./configure --prefix=/where/you/want/to/install # install to where you have access
make -j && make install # may require extra privileges depending on where to install

Under the install directory, there are two directories: binshare. The ctags executable is in the bin directory. We need to add this bin directory to the system PATH variable:

# suppose that you have install ctags to $HOME/tools/ctags
echo export PATH=$HOME/tools/ctags/bin:$PATH >> ~/.bash_profile
source ~/.bash_profile

For Mac OS#

For Mac OS, if you have installed Homebrew, you can simply using the following command to install ctags:

brew install --HEAD universal-ctags/universal-ctags/universal-ctags

Homebrew will do everything for you. No need to set up install path.

Install tagbar#

Then install tagbar with your favorite plugin manager such as vim-plug:

Use :PlugInstall to install tagbar.

Using tagbar#

Open your code and use :TarbarToggle to toggle the tagbar window. You should be able to see the tagbar window with all your classes, methods and variables.

In the above image, the window on the right is the tagbar window.

If you frequently use tagbar, you should consider adding a shortcut for this command like the following:

nnoremap <silent> <C-K><C-T> :TagbarToggle<CR>

Tagbar also provides some shortcut for tag operation. Place the cursor on some tags in the tagbar window:

  • <Enter>: go to the line in the code where the tag occur, the cursor will be in the source code
  • p: Like the <Enter> key, except that the cursor is still in tagbar window
  • q: quit the tagbar window

References#