How do I tune Vim diff so moved code blocks align more accurately?
:set diffopt+=internal,algorithm:histogram,indent-heuristic
Default diff settings are fine for small edits, but they can produce noisy hunks when code is moved or indentation shifts.
2277 results for "@a"
:set diffopt+=internal,algorithm:histogram,indent-heuristic
Default diff settings are fine for small edits, but they can produce noisy hunks when code is moved or indentation shifts.
qa ... j@bj q
You can create macros that call other macros, applying different operations to alternate lines or creating complex editing patterns.
has('nvim')
The has() function tests whether a feature or capability is available, returning 1 (true) or 0 (false).
:set diffopt+=algorithm:patience
Vim's default diff algorithm (Myers) can produce noisy diffs when working with code — it sometimes matches unrelated lines containing common tokens like {, },
/\v
Vim's default regex syntax requires backslashes before most special characters like +, (, ), {, and , which is the opposite of what most developers expect from
cgn
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
:set nowrap
The nowrap option prevents long lines from wrapping to the next screen line.
"+yy
The "+yy command yanks the current line directly to the system clipboard register, making it available for pasting in other applications.
crs / crm / crc / cru
The vim-abolish plugin by Tim Pope adds a cr (coerce) prefix command that instantly converts the word under the cursor between common naming conventions.
:set jumpoptions=stack,view
By default, jump navigation can feel lossy in long files: you jump back, but folds, topline, and viewport context do not always match what you were looking at b
J (in visual mode)
In visual mode, pressing J joins all selected lines into a single line with spaces between them.
:Make (vim-dispatch)
vim-dispatch by Tim Pope provides asynchronous build commands in Vim.
[#
Vim includes built-in motions for navigating C preprocessor conditional blocks: [# jumps backward to the previous unmatched #if or #else, and ]# jumps forward t
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim-plug is a minimalist plugin manager for Vim.
:diffget / :diffput
When comparing two files side by side with :diffsplit or vim -d, you often want to pull specific changes from one file into another rather than accepting all di
:set scrolloff=999
By default, Vim only scrolls the viewport when the cursor reaches the very top or bottom of the screen.
navigation #navigation #scrolling #config #cursor #scrolloff
[d
The [d command searches from the beginning of the file for the first line matching the define pattern for the word under the cursor, and displays it in the stat
:windo lcd %:p:h<CR>
When multiple splits point at files from different projects, relative-path commands can become inconsistent and error-prone.
U, u, or ~ in visual mode
How it works When you have text selected in visual mode, you can change its case with three simple keys: U - Convert the entire selection to UPPERCASE u - Conve
:t.
The :t (short for :copy) command copies lines from one location to another.