sponsor Vim development Vim logo Vim Book Ad

basic Tip #208: Alter the display of buffers in the buffers menu

 tip karma   Rating 10/4, Viewed by 805 

created:   January 31, 2002 9:51      complexity:   basic
author:   Roger Pilkey      as of Vim:   6.0

If you use the buffers menu, here's where you can change how the buffernames are displayed:

menu.vim, function s:BMMunge

OLD:   let name2 = name2 . ' (' . a:bnum . ')'

displays:
  
  .vimrc (1)
  menu.vim (2)


NEW:    let name2 = '&' . a:bnum . '. ' . name2

displays
  
  1. .vimrc
  2. menu.vim
(with the 1 and the 2 underlined)

which is more useful, because you can (almost) always pick the buffer you want with one keystroke, the buffernumber, until you get to buffer 10 anyway.

Roger

 rate this tip  Life Changing Helpful Unfulfilling 

<<editing databases with Vim/Perl/DBI | backtracking your movements in a file >>

Additional Notes

Anonymous, October 15, 2002 10:12
Great tip.  I changed it so that if you have more than 9 buffers, you get the numbers for 1-9, and for the others you can type the first letter of the filename (which still may not be unique, of course, in which case it will take more keystrokes to select it).

    if a:bnum >= 10
      let name2 = name2 . ' (' . a:bnum . ')'
    else
      let name2 = '&' . a:bnum . '. ' . name2
    endif

Dana
rpilkey at magma.ca, June 24, 2003 9:24
This tip didn't work in the vim 6.2 menu.vim.  Someone added this line a couple of lines down (line 702):

let name = substitute(name, "&", "&&", "g")

so to make this tip work again, comment out this line.

Rog


If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo