A Vim variable (bno) contains a buffer number. How do I use this variable to open the corresponding buffer?
: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.