How do you switch to a buffer by its number?
:b3
Use :b followed by the buffer number.
105 results for "buffer number"
:b3
Use :b followed by the buffer number.
:bd 3
Use :bd (bdelete) followed by the buffer number.
:b {number}
The :b command followed by a buffer number switches directly to that buffer.
:b N
How it works Every buffer in Vim is assigned a unique number when it is opened.
vim.wo.number = true / vim.bo.tabstop = 2
Neovim's Lua API exposes three namespaces for setting options with the correct scope: vim.
:%s/\d\+/\=printf('%04d', submatch(0))/g
When you need fixed-width numeric fields, manually editing each number is slow and error-prone.
:%s/\v(\d+)/\=printf('%04d', submatch(1))/g
When you need stable-width numeric fields, manual edits are slow and error-prone.
command-line #command-line #substitution #regex #refactoring
:sbuffer {N}
:sbuffer {N} opens buffer number N in a new horizontal split, leaving your current window untouched.
buffers-windows #buffers-windows #buffers #windows #navigation
:ls
The :ls command displays a list of all open buffers in Vim, showing their buffer number, status indicators, file name, and the line the cursor was last on.
:sb 3
Use :sb (sbuffer) followed by the buffer number to open that buffer in a new horizontal split.
<C-w>^
Vim tracks the alternate buffer — the last file you were editing before the current one.
:[range]luado {lua-expr}
Neovim's :luado command runs a Lua expression on each line of a range, allowing you to transform text using the full power of Lua's string library.
:options
:options opens a special Vim buffer that lists every available option, grouped by category (appearance, editing, search, etc.
/\%>20l\%<40lTODO
Vim's search engine can constrain matches by line number, which is useful when you want to scan a known section without touching the rest of the buffer.
:%s/pattern//n
The n flag in the substitute command suppresses the actual replacement and instead reports the match count.
yos, yow, yol, yon, yoh
The vim-unimpaired plugin adds a set of paired bracket mappings, including a powerful family of option toggles.
<C-w>F
F opens the filename under the cursor in a new horizontal split window and jumps to the line number that follows the filename.
buffers-windows #navigation #buffers-windows #windows #editing
:let i=0 | g/pattern/s/pattern/\=printf('%d', i+=1)/
By combining :let, the :g global command, and an expression substitution with \=, you can replace every match of a pattern with a unique incrementing number.
:set option
The :set command changes Vim options for the current session.
:bdelete
How it works The :bdelete command (often abbreviated :bd) removes the current buffer from Vim's buffer list and closes it.