How do I run a command on every open buffer?
:bufdo command
The :bufdo command executes an Ex command on every buffer in the buffer list.
:bufdo command
The :bufdo command executes an Ex command on every buffer in the buffer list.
:ball
The :ball command opens a window for every buffer in the buffer list.
:diffthis in both windows
The :diffthis command enables diff mode for the current buffer.
:bp | bd #
The :bp bd # command switches to the previous buffer and then deletes the alternate buffer.
:lnext and :lprev
The location list is a per-window alternative to the quickfix list.
:cnext and :cprev
The quickfix list holds a set of file positions, typically from compiler errors, grep results, or other tools.
gF
The gF command opens the file under the cursor and jumps to the line number that appears after the filename.
let g:netrw_liststyle=3 and let g:netrw_banner=0
How it works Vim ships with a built-in file explorer called netrw that you can access with :Explore (or :Ex).
:set backupdir=~/.vim/backup// directory=~/.vim/swap//
How it works By default, Vim creates backup files (ending in ~) and swap files (ending in .
:set autowriteall and autocmd FocusLost * silent! wa
How it works Vim can be configured to automatically save your files when you switch to another window or application.
:'<,'>w filename
How it works Vim's :w command can take a range, and when used with a visual selection, it writes only the selected lines to a file.
:nnoremap <buffer> <leader>r :!python %<CR>
How it works By adding to a mapping command, the mapping only applies to the current buffer.
:!ls -la
Vim lets you execute any shell command directly from within the editor using the :! (bang) command.
:%bd | e#
How it works Vim does not have a built-in single command to close all buffers except the current one, but you can achieve this with a two-part command: :%bd e#.
:tab sb N
How it works The :tab sb N command opens buffer number N in a brand new tab page.
<C-w>f
How it works You may already know that gf opens the file path under the cursor in the current window.
:DB sqlite:mydb.sqlite SELECT * FROM users
vim-dadbod by Tim Pope is a plugin that lets you interact with databases directly from Vim.
:b N
How it works Every buffer in Vim is assigned a unique number when it is opened.
:bdelete
How it works The :bdelete command (often abbreviated :bd) removes the current buffer from Vim's buffer list and closes it.
<C-w>+
When working with multiple split windows, you often need to resize them to see more content in one pane.