How do I open the current file in a preview window at a specific pattern?
:pedit +/TODO %
When you need a second read-only view of the same file, opening more normal splits can disrupt your working layout.
:pedit +/TODO %
When you need a second read-only view of the same file, opening more normal splits can disrupt your working layout.
:setlocal winfixheight
Quickfix windows are easy to disturb when you open, close, or rebalance other splits.
:psearch /pattern/
When you need quick context from another file but do not want to disturb your current editing window, :psearch gives you a clean workflow.
buffers-windows #buffers #windows #preview-window #search #navigation
:set switchbuf+=uselast
When jumps open the target buffer in an unexpected split, context switching gets expensive.
:leftabove sbuffer #
If you often compare your current file against the previously visited buffer, replacing the current window is disruptive.
:windo setlocal scrollbind
When reviewing related files side by side, manually keeping splits aligned wastes attention.
:set splitkeep=topline
When you open, close, or resize splits in long files, the visible window region can shift in ways that break your reading flow.
:keepalt edit path/to/file\<CR>
Experienced Vim workflows often depend on the alternate file (#) for fast toggling with , quick diffs, or two-file review loops.
:windo setlocal scrollbind cursorbind
When reviewing related files side by side, alignment drifts quickly if each window scrolls independently.
buffers-windows #buffers-windows #windows #scrolling #comparison
:tab sbuffer
Sometimes you want a second workspace for the same file: one tab for broad navigation, another for focused edits or test-driven jumps.
buffers-windows #buffers-windows #tabs #workflow #navigation
:set noequalalways
When you work with carefully sized splits, Vim's default behavior can feel disruptive: opening or closing a window triggers an automatic rebalance.
:keepalt sbuffer {bufnr}
The alternate-file register (#) is easy to disturb when jumping around buffers, and many advanced motions depend on it (, # expansions, quick two-file toggles).
:hide edit {file}<CR>
Normally, trying to :edit another file from a modified buffer triggers a warning and blocks the switch unless you save or force the command.
buffers-windows #buffers #windows #workflow #command-line #editing
:setlocal winfixheight winfixwidth
If you use a dedicated utility pane (logs, quick notes, REPL output), Vim's default equalization behavior can keep resizing it whenever other splits change.
:lgetexpr systemlist('rg --vimgrep TODO %') | lopen
When you want search results tied to only the current window, use :lgetexpr instead of :cgetexpr.
buffers-windows #location-list #quickfix #buffers #command-line #search
:windo diffthis<CR>
If you already have several related files open in splits, enabling diff mode one window at a time is slow and error-prone.
buffers-windows #buffers-windows #diff #windows #ex-commands
:vnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
For quick throwaway notes, command output cleanup, or temporary edits, a normal buffer is noisy: it appears in :ls, can prompt you to save, and may leave swap a
buffers-windows #buffers-windows #buffers #windows #scratch #workflow
:bufdo keeppatterns %s/\s\+$//e | update
If you keep many files open during a refactor, cleaning trailing whitespace one buffer at a time is slow and error-prone.
<C-w>TgT
When a split temporarily becomes the center of attention, promoting it to its own tab can reduce layout noise.
:wincmd r
When a split layout is correct but the window positions are awkward, you do not need to close and reopen anything.