1

When I am using vim buffers, I like to look at the status bar instead of using :ls to see which number is associated with the vim buffer.

This becomes problematic when there are multiple files of the same name. Then, the status bar for vim-airline will show:

4: handler.py 10: handler.py 22: handler.py

Is there a way to show some part of the filepath when there are files of the same name?

Surprisingly, I thought this would be a common issue but could not find a solution online.

Thanks

prajmus
  • 3,171
  • 3
  • 31
  • 41
Delos Chang
  • 1,823
  • 3
  • 27
  • 47

1 Answers1

1

You are basically using airline to create some kind lookup table. This means you have to not only find your file on the status bar but remember a buffer number and buffer numbers are lame.

The many ways to switching buffers

  • :sb and :b both can take partial names and globs. e.g. :sb foo*
  • :b/:sb use tab completion when used with partial names
  • Use :sb to switch and split to a buffer you already opened.
  • Use :ls and :b together in a mapping: nnoremap <leader>b :ls<cr>:b<space>
  • <c-6> will go the the previous buffer (can also take an optional buffer number)
  • Map :bnext and :bprev example [b and ]b are Unimpaired.vim mappings
  • set hidden make switching buffers easier. Don't worry vim will let you know if you have unwritten buffer before exiting
  • Use capital letter marks to jump back to buffers where you know you will jump back to.
  • Use tags to jump to definitions.
  • Possibly use cscope along with tags
  • Look into fuzzy finder plugsin like CtrlP, Command-T, and Unite to switch buffers
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101