Re: delete buffers matching pattern

2006-07-19 Thread Tim Chase

:bufdo if bufname("%")=~?'.exe$' | bdel | endif


 I think you want to escape the dot:

:bufdo if bufname("%") =~? '\.exe$' | bdel | endif


Oh, so correct.  My error.  It's one of those subtle things that 
works just fine until it bites you in the bum when one has file 
extensions such as the hypothetical "filename.annexe" (a quick 
grep of my /usr/share/dict/british-english returned that as the 
only word ending in "exe")



(Optional spaces added because I find it more readable that way.)


yes, if I have to come back and read my code later, extra spaces 
are a nice touch...but for these one-line run-it-and-forget-it 
things, I tend to be a little more compact (a genteel way of 
saying "lazy" :)


-tim





Re: delete buffers matching pattern

2006-07-19 Thread Benji Fisher
On Mon, Jul 17, 2006 at 10:59:41AM -0500, Tim Chase wrote:
> >Is there a way to delete all buffers matching a certain pattern?
> >For example, suppose I just read in all files in a directory and this is 
> >my buffer list:
> >1 "a.txt"
> >2 "b.txt"
> >3 "1.exe"
> >4 "2.exe"
> >5 "c.txt"
> >6 "3.exe"
> >7 "d.txt"
> >
> >I want to do something like ":bdelete *.exe".
> 
> The following seems to do the trick for me:
> 
>   :bufdo if bufname("%")=~'.exe$' | bdel | endif
> 
> or its case-insensitive cousin
> 
>   :bufdo if bufname("%")=~?'.exe$' | bdel | endif

 I think you want to escape the dot:

:bufdo if bufname("%") =~? '\.exe$' | bdel | endif

(Optional spaces added because I find it more readable that way.)

HTH --Benji Fisher


Re: delete buffers matching pattern

2006-07-17 Thread Tim Chase

Is there a way to delete all buffers matching a certain pattern?
For example, suppose I just read in all files in a directory and this is 
my buffer list:

1 "a.txt"
2 "b.txt"
3 "1.exe"
4 "2.exe"
5 "c.txt"
6 "3.exe"
7 "d.txt"

I want to do something like ":bdelete *.exe".


The following seems to do the trick for me:

:bufdo if bufname("%")=~'.exe$' | bdel | endif

or its case-insensitive cousin

:bufdo if bufname("%")=~?'.exe$' | bdel | endif


HTH,

-tim





delete buffers matching pattern

2006-07-17 Thread Wim R. Crols

Is there a way to delete all buffers matching a certain pattern?
For example, suppose I just read in all files in a directory and this is 
my buffer list:

1 "a.txt"
2 "b.txt"
3 "1.exe"
4 "2.exe"
5 "c.txt"
6 "3.exe"
7 "d.txt"

I want to do something like ":bdelete *.exe".
I don't want to manually enumerate all the buffer nummers like ":bdelete 
3 4 6"


Thanks,
Wim