How do I filter a range of text through an external shell command directly in normal mode?
The ! operator in normal mode lets you pipe any motion's text through a shell command and replace it with the output.
category:
editing
tags:
#editing
#shell
#external-command
#normal-mode
#filtering
How do I run a normal mode command that bypasses all user-defined key mappings?
The :normal! command (abbreviated :norm!) executes a sequence of Normal mode keystrokes while completely ignoring user-defined mappings and abbreviations.
category:
command-line
tags:
#ex-commands
#normal-mode
#macros
#scripting
How do I extract regex capture groups from a string in Vimscript?
matchlist({str}, {pattern}) runs a regex match and returns a list of all captured groups, making it the idiomatic way to extract structured data from strings in
category:
macros
tags:
#vimscript
#macros
#ex-commands
#search
How do I move the cursor to the other end of a visual selection without restarting it?
In visual mode, pressing o swaps the cursor between the two ends of the selection (the anchor and the free end).
category:
visual-mode
tags:
#visual-mode
#navigation
#editing
How do I trigger an autocommand action after the cursor has been idle for a set period?
The CursorHold autocommand event fires once whenever the cursor has been motionless in normal mode for updatetime milliseconds.
category:
config
tags:
#config
#autocommands
#events
#insert-mode
How do I convert all tabs to spaces in a file in Vim?
How it works The :retab command replaces all tab characters in the current buffer with the appropriate number of spaces, based on your current tabstop and expan
category:
editing
tags:
#editing
#ex-commands
#formatting
How do I programmatically read and write Vim register contents including their type from Vimscript?
The setreg(reg, value, type) and getreg(reg, 1, 1) functions give you full programmatic control over registers, including their type (characterwise, linewise, o
category:
registers
tags:
#registers
#vimscript
#macros
#ex-commands
How do I restrict a substitute command to only the text within my last visual selection using the percent-V atom?
The \%V atom in Vim's regex engine matches only within the area of the last visual selection.
category:
search
tags:
#search
#visual-mode
#substitute
#advanced
#ex-commands
How do I hard-wrap a paragraph to fit within textwidth without moving my cursor away from it?
The gw operator reformats text to fit within 'textwidth' — identical in effect to gq, but with one key difference: the cursor returns to its original position
category:
editing
tags:
#editing
#formatting
#text-objects
#normal-mode
How do I search for and highlight text that exceeds a specific column width like 80 or 120?
The pattern /\%>80v.
category:
search
tags:
#search
#navigation
#normal-mode
How do I set a Vim option for only the current buffer or window without affecting others?
:setlocal {option}={value}
:setlocal sets an option only for the current buffer or window, leaving all other buffers and windows unaffected.
category:
config
tags:
#config
#ex-commands
How do I filter a range of text through an external shell command in Vim?
The ! operator passes text selected by a motion through an external shell command, replacing it with the command's output.
category:
editing
tags:
#editing
#normal-mode
#ex-commands
How do I quickly jump between a small set of frequently used files?
Harpoon: mark files and jump with <leader>1-4
Harpoon by ThePrimeagen provides instant access to a curated list of files you're actively working on.
category:
plugins
tags:
#plugins
#navigation
#neovim
#harpoon
#workflow
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
How do I turn custom command output like file:line:col:message into a navigable quickfix list?
:setlocal errorformat=%f:%l:%c:%m | cexpr system('tool %') | copen
Not every linter or internal script speaks Vim quickfix format out of the box.
category:
command-line
tags:
#command-line
#quickfix
#errorformat
#linting
#workflow
How do I jump to the beginning of a file in Vim?
The gg command moves the cursor to the first line of the file.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I keep a horizontal margin between the cursor and the edge of the screen when scrolling sideways?
set sidescrolloff={n} keeps at least n columns of context to the left and right of the cursor when long lines cause the view to scroll horizontally.
category:
config
tags:
#config
#navigation
#normal-mode
How do I center, right-justify, or left-justify lines of text in Vim without a plugin?
:'<,'>center / :'<,'>right / :'<,'>left
Vim has built-in Ex commands to align text within a specified width: :center, :right, and :left.
category:
editing
tags:
#editing
#visual-mode
#formatting
#ex-commands
How do I open a URL under the cursor in my web browser from Vim?
The gx command opens the URL, file path, or identifier under the cursor using the system's default handler.
category:
navigation
tags:
#navigation
#netrw
#workflow
#browser
#normal-mode
How do I copy a character from the line above or below while in insert mode?
When typing in insert mode, you can pull individual characters from adjacent lines without leaving insert mode.
category:
editing
tags:
#insert-mode
#editing
#completion