Tom
Tom

Reputation: 6971

How can I pass a variable as an argument to the buffer command in Vim?

I want to do something like:

let b = bufnr('%')
" do something that adds (potentially loads of) new buffers
buffer b

But I get the error

"No matching buffer for b"

How can "expand" the variable b, or work around this in some other way?

Upvotes: 3

Views: 238

Answers (1)

Luc Hermitte
Luc Hermitte

Reputation: 32926

Have you tried:

:exe "buffer ".b

For more information:

:h :exe

Upvotes: 2

Related Questions