How do I prevent Vim's write strategy from breaking LSP file watchers by changing a file's inode on save?
By default, Vim saves files using a "write-then-rename" strategy: it writes to a temporary backup file and then renames it over the original.
category:
config
tags:
#config
#neovim
#lsp
How do I move to the opposite corner of a visual block selection?
In visual block mode (), pressing O (uppercase) moves the cursor to the diagonally opposite corner of the rectangular selection.
category:
visual-mode
tags:
#visual-mode
#editing
#navigation
How do I extract the directory, filename, or extension from the current file path inside a Vim command?
Vim's filename modifiers let you derive path components from the current buffer's filename directly on the command line.
category:
command-line
tags:
#ex-commands
#command-line
#editing
How do I save a file only if it has unsaved changes, without touching the file timestamp if nothing changed?
The :update command (abbreviated :up) writes the buffer to disk only if it has been modified since the last save.
category:
command-line
tags:
#ex-commands
#buffers
#editing
How do I create a Visual selection for the previous search match instead of the next one?
Most users know gn for selecting the next search match, but its counterpart gN is the real power move when you need to work backward through matches.
category:
visual-mode
tags:
#visual-mode
#search
#motions
#editing
#normal-mode
How do I run a macro on every line in the file silently, ignoring errors on lines where the macro fails?
Combining :silent!, the % range, and :normal @q gives you a powerful pattern for applying a macro across an entire file while gracefully skipping lines that don
category:
macros
tags:
#macros
#editing
#ex-commands
#normal-mode
How do I copy lines to a different location in the file without overwriting my yank register?
The :t command (short for :copy) copies addressed lines to a destination line number, leaving the unnamed register untouched.
category:
command-line
tags:
#ex-commands
#editing
#normal-mode
#registers
How do I customize which patterns Vim considers a definition for [d and ]d jump commands?
Vim's [d, ]d, [D, and ]D commands search for the "definition" of the keyword under the cursor.
category:
config
tags:
#config
#navigation
#search
#tags
#ex-commands
How do I copy a character from the line directly above or below while staying in insert mode?
In Insert mode, copies the character at the same column position from the line above the cursor, and copies the character from the line below.
category:
editing
tags:
#insert-mode
#editing
#copy
How do I apply a macro across multiple files at once?
:argdo normal @q | update
The :argdo command runs a command in every file in the argument list.
category:
macros
tags:
#macros
#batch-editing
#multi-file
#ex-commands
#workflow
How do I open a URL or file from Neovim using the system's default application?
vim.
category:
command-line
tags:
#neovim
#lua
#config
#command-line
How do I create a self-repeating macro that runs until there is nothing left to process?
@q (inside macro recording)
A recursive macro calls itself as its last action, causing it to repeat indefinitely until it hits an error (like reaching end of file or failing a search).
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I make a macro repeat itself until it reaches the end of the file?
A recursive macro calls itself at the end of its recording, causing it to repeat automatically until a motion fails (like j at the last line).
category:
macros
tags:
#macros
#editing
#normal-mode
#registers
How do I wrap a word in quotes or brackets using vim-surround?
The ysiw" command wraps the word under the cursor in double quotes using the vim-surround plugin.
category:
plugins
tags:
#plugins
#text-objects
#editing
#insert-mode
How do I jump to a tag in Vim and automatically choose if there is only one match?
Vim's :tjump is the smarter sibling of :tag and :tselect.
category:
navigation
tags:
#navigation
#tags
#ctags
#search
How do I delete all blank lines in a file?
The :g/^$/d command deletes every blank line in the file using Vim's powerful global command.
category:
command-line
tags:
#editing
#ex-commands
#search
#formatting
How do I load plugins without a plugin manager using Vim's built-in package system?
Since Vim 8 and Neovim, Vim has a built-in package system that can load plugins directly from the filesystem — no external plugin manager required.
category:
plugins
tags:
#plugins
#config
#ex-commands
How do I pull a diff change from another window into the current buffer in Vim?
The do command (diff obtain) is shorthand for :diffget.
category:
buffers-windows
tags:
#diff
#buffers
#editing
#normal-mode
How do I create a macro that runs itself repeatedly until it fails?
A recursive macro calls itself at the end of its recording, creating a loop that repeats until a motion or command fails (like reaching the end of the file or f
category:
macros
tags:
#macros
#editing
#normal-mode
#automation
#advanced
How do I programmatically inject keystrokes into Vim's input queue from a function or mapping?
The feedkeys({keys}, {flags}) function inserts a string of keystrokes into Vim's input queue as if the user had typed them.
category:
command-line
tags:
#ex-commands
#macros
#config
#normal-mode