Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

A Vim variable (bno) contains a buffer number. How do I use this variable to open the corresponding buffer?

bno buffer Vim
0
Posted

A Vim variable (bno) contains a buffer number. How do I use this variable to open the corresponding buffer?

0

:buffer command will not accept a variable name. It accepts only a buffer number or buffer name. You have to use the “:execute” command to evaluate the variable into the corresponding value. For example: :execute “buffer ” . bno For more information, read :help :execute 25.15. How do I store the value of a Vim option into a Vim variable? You can prefix the option name with the ‘&’ character and assign the option value to a Vim variable using the “let” command. For example, to store the value of the ‘textwidth’ option into the Vim variable “old_tw”, you can use the following command: :let old_tw = &tw To do the opposite, to set the ‘textwidth’ option with the value stored in the ‘old_tw’ variable, you can use the following command: :let &tw = old_tw For more information, read :help expr-option :help let-option 25.16.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123