How do I quickly switch between the current file and the last edited file?
Pressing (Ctrl-6 on most keyboards) instantly toggles between the current buffer and the alternate file — the last file you were editing.
category:
buffers-windows
tags:
#navigation
#buffers
#normal-mode
#productivity
#windows
How do I close all buffers except the current one in Vim?
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#.
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation
How do I force Vim to check if open files were changed externally and reload them?
The :checktime command tells Vim to check whether any open buffers have been modified outside of Vim and prompt you to reload them.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
How do I list all lines matching a pattern across the current file and its includes?
The :ilist command searches for a pattern not only in the current buffer but also in files referenced by #include directives (or whatever 'include' is set to).
category:
search
tags:
#search
#ex-commands
#navigation
#editing
How do I rotate split windows forward without reopening any buffers?
When a split layout is correct but the window positions are awkward, you do not need to close and reopen anything.
category:
buffers-windows
tags:
#windows
#buffers
#command-line
#navigation
How do I build a custom statusline without plugins?
:set statusline=%f\ %m%r%h%w\ %=%l/%L\ %p%%
Vim's statusline option accepts printf-style format codes that display file info, position, mode, and any custom expression.
category:
config
tags:
#config
#statusline
#vimrc
#customization
How do I save my current window and return to it after navigating other windows from a script or function?
:let winid = win_getid() | ... | call win_gotoid(winid)
The wingetid() and wingotoid() functions let you bookmark a window by its stable integer ID and jump back to it reliably.
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
#macros
How do I capture the output of a Vim command into a register or buffer?
:redir @a | {cmd} | redir END
The :redir command redirects the output of Ex commands to a register, file, or variable instead of displaying it on the screen.
category:
command-line
tags:
#command-line
#ex-commands
#registers
#productivity
#advanced
How do I programmatically populate the quickfix list from Vimscript?
setqflist() lets you build the quickfix list from a Vimscript list of dictionaries rather than relying on compiler output or :vimgrep.
category:
command-line
tags:
#ex-commands
#buffers
How do I save multiple different views of the same file with independent fold and cursor states?
:mkview 2 and :loadview 2
Vim supports up to 9 numbered view slots per file.
category:
buffers-windows
tags:
#folding
#buffers-windows
#navigation
#config
How do I read man pages inside Neovim with syntax highlighting and tag navigation?
Neovim ships with a built-in :Man command (the man.
category:
command-line
tags:
#neovim
#navigation
#documentation
#command-line
How do I run the same command across all windows, buffers, or tabs?
:windo / :bufdo / :tabdo {command}
Vim's do commands iterate over collections and execute a command in each context.
category:
buffers-windows
tags:
#buffers
#windows
#tabs
#batch-editing
#ex-commands
How do I quickly switch between the current file and the last file I was editing?
:e # opens the alternate file — the file you were editing just before the current one.
category:
buffers-windows
tags:
#buffers
#editing
#ex-commands
#navigation
How do I jump to a tag in a new split window showing all matching tags?
g] splits the window and then runs :tselect for the identifier under the cursor, displaying a numbered list of all matching tags so you can pick the exact defin
category:
buffers-windows
tags:
#navigation
#buffers
#windows
#tags
How do I look up documentation for the keyword under the cursor?
Pressing K in normal mode runs a lookup program on the word under the cursor.
category:
navigation
tags:
#navigation
#help
#documentation
#normal-mode
#keywordprg
How do I programmatically find the project root directory in Neovim Lua based on marker files?
vim.
category:
config
tags:
#neovim
#lua
#project
#lsp
#filesystem
How do I make Vim automatically jump to where I last edited when reopening a file?
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
Vim remembers the last cursor position for every file you edit (stored in the viminfo or shada file), but by default it opens files at line 1.
category:
config
tags:
#config
#autocmd
#navigation
#vimrc
#productivity
How do I view a side-by-side Git diff of staged changes inside Vim?
The vim-fugitive plugin provides :Gdiffsplit (and its vertical variant :Gvdiffsplit) to open a side-by-side diff view comparing the working tree version of a fi
category:
plugins
tags:
#plugins
#fugitive
#git
#diff
#staging
How do I undo all changes made in the last N minutes using time-based undo?
Vim's :earlier command lets you travel back through the undo history by wall-clock time rather than by the number of changes.
category:
editing
tags:
#undo-redo
#editing
#ex-commands
How do I define a custom user command in Neovim Lua config that accepts arguments and has a description?
vim.api.nvim_create_user_command()
Neovim's Lua API provides vim.
category:
config
tags:
#config
#neovim
#lua
#command-line
#ex-commands