Wikia

Vim Tips Wiki

Changes: Alter the display of buffers in the buffers menu

Edit

Back to page

(Adding categories)
(Insert TipProposed template + minor manual clean)
 
Line 4: Line 4:
 
|previous=207
 
|previous=207
 
|next=210
 
|next=210
|created=January 31, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=Roger Pilkey
 
|author=Roger Pilkey
Line 12: Line 12:
 
|category2=
 
|category2=
 
}}
 
}}
If you use the buffers menu, here's where you can change how the buffernames are displayed:
+
If you use the buffers menu, here is where you can change how the buffernames are displayed:
 
 
<pre>
 
<pre>
 
menu.vim, function s:BMMunge
 
menu.vim, function s:BMMunge
Line 31: Line 31:
 
==Comments==
 
==Comments==
 
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).
 
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).
 
 
<pre>
 
<pre>
 
if a:bnum >= 10
 
if a:bnum >= 10
Line 42: Line 41:
 
----
 
----
 
This tip didn't work in the vim 6.2 menu.vim. Someone added this line a couple of lines down (line 702):
 
This tip didn't work in the vim 6.2 menu.vim. Someone added this line a couple of lines down (line 702):
+
<pre>
let name = substitute(name, "&", "&&", "g")
+
let name = substitute(name, "&", "&&", "g")
  +
</pre>
   
 
so to make this tip work again, comment out this line.
 
so to make this tip work again, comment out this line.
   
 
----
 
----
[[Category:buffers]]
 
[[Category:menu]]
 

Latest revision as of 03:49, January 6, 2010

Tip 208 Printable Monobook Previous Next

created 2002 · complexity basic · author Roger Pilkey · version 6.0


If you use the buffers menu, here is 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.

CommentsEdit

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

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.


Around Wikia's network

Random Wiki