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

推荐订阅源

MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
V
Visual Studio Blog
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
L
LangChain Blog
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
P
Proofpoint News Feed
博客园_首页
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog

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 Switch between Buffers Quickly in Neovim/Vim
2018-09-29 · via jdhao's digital space

When working on real projects using Neovim, we often open several files in a window. Each file corresponds to a buffer. How to switch between these buffers quickly?

To show a list of opened buffers, we can use the :buffers command. Below is an example output:

3      "train.py"                     line 1
4 %a   "main.py"                      line 17
6      "keys.py"                      line 1
7      "utils.py"                     line 1
8 #    "val_CTC.py"                   line 2

The first number is a unique buffer number corresponding to each buffer.

The native way#

In command mode, some of the commands to change buffers are list below:

  • :bfirst: change to first buffer in the buffer list
  • :blast: change to last buffer in the buffer list
  • :bnext: change to next buffer
  • :bprevious: change to previous buffer

Or you can use :b <TAB> to choose from currently opened buffers.

If there are a few buffers, it is easy to switch using the above command. However, if we have a dozen of opened buffers, it is cumbersome to use these commands.

Switching buffers using buffer number#

We can switch to a buffer quickly if we know its number. If we know the number of a buffer, we can use NUM Ctrl-6 to go to a particular buffer (replace NUM with actual buffer number). For example, to switch to main.py, we will press 4<C-6>.

This is still inconvenient — since we have to find the buffer number first.

A better solution for buffer switching#

If you have installed vim-airline ,you can configure it to show the buffer number on the top of the window tabline. Just add the following settings to Nvim config file init.vim:

let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1

Restart Nvim and you will find that each buffer has a number on the left of the file name. Then you can easily go to a buffer.

If you do not want to use vim-airline, there are other plugins to show a buffer tabline, such as buf-tabline, which is more lightweight.

References#