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 write vimrc configuration that works in both Vim and Neovim by detecting which one is running?
The has() function tests whether a feature or capability is available, returning 1 (true) or 0 (false).
category:
config
tags:
#config
#vimscript
#compatibility
How do I open another file without changing the alternate-file mark (#)?
The alternate-file mark (#) powers fast toggles like and commands that depend on the previous file context.
category:
command-line
tags:
#command-line
#buffers
#workflow
#navigation
#advanced
How do I safely use a filename containing special characters in a Vim Ex command?
When building Vim Ex commands dynamically, filenames with spaces, , %, #, [, or other special characters will be misinterpreted — the space looks like an argu
category:
config
tags:
#ex-commands
#normal-mode
How do I run a window-local setting command in every open window?
:windo setlocal colorcolumn=+1
When a setting is window-local, changing it once does not affect your other splits.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#formatting
How do I populate a window-local location list for only the current file using ripgrep output?
:call setloclist(0, [], 'r', {'title': 'TODO current file', 'lines': systemlist('rg --vimgrep TODO ' . shellescape(expand('%:p'))), 'efm': '%f:%l:%c:%m'})
For focused review work, a window-local location list is often better than global quickfix.
category:
buffers-windows
tags:
#buffers
#windows
#location-list
#search
#quickfix
How do I run the same Ex command in every open window at once?
:windo {cmd} executes an Ex command in every window in the current tab page, cycling through each one and applying the command before returning focus to the ori
category:
buffers-windows
tags:
#windows
#buffers
#ex-commands
#buffers-windows
How do I improve Vim diff readability for moved or reindented code blocks?
:set diffopt+=algorithm:histogram,indent-heuristic
Default diff behavior can produce noisy hunks when code is moved or indentation changes significantly.
category:
config
tags:
#config
#buffers-windows
#ex-commands
#formatting
How do I make the focused window automatically expand to a minimum size while keeping other windows visible?
:set winwidth=85 winheight=20
Setting winwidth and winheight tells Vim the minimum column width and line height the current focused window must have.
category:
buffers-windows
tags:
#windows
#buffers
#config
#navigation
How do I set each window's local working directory to its buffer path?
When multiple splits point at files from different projects, relative-path commands can become inconsistent and error-prone.
category:
buffers-windows
tags:
#buffers
#windows
#command-line
#workflow
How do I edit a file without overwriting the alternate buffer?
Every time you open a file with :edit, Vim updates the alternate file register (#) to the previous buffer.
category:
buffers-windows
tags:
#buffers
#ex-commands
#registers
#navigation
How do I show the current buffer in a new tab without re-reading it from disk?
Sometimes you want a second workspace for the same file: one tab for broad navigation, another for focused edits or test-driven jumps.
category:
buffers-windows
tags:
#buffers-windows
#tabs
#workflow
#navigation
How do I open an already-loaded buffer in a new tab without re-reading it from disk?
If a file is already loaded as a buffer, reopening it with :tabedit can trigger another read and may lose the exact in-memory context you want.
category:
buffers-windows
tags:
#buffers
#windows
#tabs
#command-line
How do I customize Vim's statusline to show useful file information?
:set statusline=%f\ %y\ [%l/%L]
Vim's statusline option lets you build a custom status bar from format items.
category:
config
tags:
#config
#formatting
How do I make gf find files even when the import path omits the file extension?
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
category:
navigation
tags:
#navigation
#config
#editing
How do I make Vim diff ignore whitespace and use patience algorithm for clearer hunks?
:set diffopt+=iwhite,algorithm:patience
When whitespace-only churn and noisy line matching make diffs hard to review, tuning diffopt can dramatically improve signal.
category:
config
tags:
#config
#diff
#review
#whitespace
How do I search across all of Vim's help documentation for a keyword or phrase?
:helpgrep searches the full text of every Vim help file for a pattern and loads all matches into the quickfix list.
category:
search
tags:
#search
#ex-commands
#navigation
How do I open or edit a file in the same directory as the file I am currently editing?
Vim expands % to the current file's path in Ex commands, and the :h modifier strips the last filename component to give you just the directory.
category:
command-line
tags:
#ex-commands
#buffers
#navigation
#editing
How do I check if a specific Vim feature or capability is available before using it in my vimrc?
The has('feature') function returns 1 if the specified feature is available in the current Vim/Neovim instance, 0 otherwise.
category:
config
tags:
#config
#vimscript
#portability
How do I open another file without saving the current modified buffer first?
Normally, trying to :edit another file from a modified buffer triggers a warning and blocks the switch unless you save or force the command.
category:
buffers-windows
tags:
#buffers
#windows
#workflow
#command-line
#editing