How do I open a file and jump directly to a specific line or pattern?
The :edit command accepts a +{cmd} prefix that executes an Ex command immediately after the file is loaded.
category:
command-line
tags:
#buffers
#ex-commands
#navigation
#command-line
How do I open a related file with a different extension using the current filename?
In Vim's command line, % expands to the current buffer's filename.
category:
command-line
tags:
#ex-commands
#command-line
#buffers
#navigation
How do I change the working directory for only the current window without affecting other windows or tabs?
:cd changes the global working directory, affecting every window and tab in the session.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#navigation
How do I open a split window that spans the full width or height of the editor instead of splitting only the current window?
When you split a window with :split or :vsplit, Vim subdivides only the current window.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#command-line
How do I see a list of recently opened files and quickly jump back to one?
:oldfiles displays a numbered list of every file Vim has recorded in its viminfo (or shada in Neovim) file.
category:
navigation
tags:
#navigation
#buffers
#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 run a substitution or command on every line in the quickfix list?
:cdo {cmd} executes {cmd} on each entry in the quickfix list — one by one, jumping to each location in turn.
category:
command-line
tags:
#ex-commands
#quickfix
#search
#editing
#buffers
How do I bookmark a position in one file and jump back to it from any other file?
Uppercase marks (A–Z) are global marks — they persist across files and Vim sessions.
category:
navigation
tags:
#navigation
#marks
#buffers
How do I open a file by name without knowing its full path?
The :find command searches for a file by name across all directories listed in Vim's path option, so you can open files without typing full paths.
category:
navigation
tags:
#navigation
#ex-commands
#buffers
#editing
How do I open the current buffer in a new tab so I can view it independently?
:tab split opens the current buffer in a brand new tab page, giving you a second independent view of the same file.
category:
buffers-windows
tags:
#tabs
#buffers
#windows
#normal-mode
How do I run a recorded macro across multiple files at once?
Combining :argdo with :norm @a lets you apply a recorded macro to every file in Vim's argument list — a powerful pattern for bulk refactoring across a project
category:
macros
tags:
#macros
#ex-commands
#editing
#buffers
How do I accept or reject individual changes in Vim's diff mode?
When reviewing differences between files in Vim's built-in diff mode, dp and do let you selectively apply individual hunks without leaving the editor.
category:
buffers-windows
tags:
#buffers
#windows
#diff
#editing
How do I save all modified buffers at once without switching to each one?
When working across multiple files, you often have unsaved changes in several buffers.
category:
command-line
tags:
#buffers
#ex-commands
#editing
How do I make gf find files when import paths omit the file extension?
:set suffixesadd+=.js,.ts,.jsx,.tsx
The gf (go to file) command opens the file under the cursor, but it fails when the path lacks an extension — common in JavaScript/TypeScript imports like impo
category:
navigation
tags:
#navigation
#config
#editing
#buffers
#file-management
How do I run the same command across all open buffers at once?
When you need to apply the same change to every file you have open in Vim, switching to each buffer manually is tedious and error-prone.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
#batch
How do I control exactly where a new split window appears in Vim?
By default, Vim places horizontal splits below and vertical splits to the right (controlled by splitbelow and splitright).
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#splits
How do I set a different statusline for a specific buffer or window?
:setlocal statusline=%f\ %m\ %y\ [%l/%L]
The :setlocal statusline command lets you override the global statusline for a specific window.
category:
config
tags:
#config
#statusline
#ex-commands
#buffers
How do I populate the quickfix list from the output of an external shell command?
:cexpr system('grep -rn TODO .')
The :cexpr command evaluates an expression and parses the result as quickfix entries using the current errorformat.
category:
command-line
tags:
#ex-commands
#search
#editing
#buffers
How do I open a file in a new tab or switch to it if it is already open?
When working with many tabs, you often want to open a file — but only if it is not already open somewhere.
category:
buffers-windows
tags:
#buffers
#tabs
#navigation
#windows
How do I diff two files that are already open in Vim splits?
You often have two files open side by side and want to compare them without leaving Vim or launching vimdiff.
category:
navigation
tags:
#buffers
#windows
#editing
#navigation