How do I create a custom operator that works with motions and text objects?
:set operatorfunc=MyFunc<CR>g@
Vim lets you define custom operators that behave like built-in ones (d, c, y) — they wait for a motion or text object, then act on the selected region.
category:
config
tags:
#config
#normal-mode
#motions
#text-objects
#mapping
How do I jump between method or function definitions in code?
When navigating large source files, ]m and [m let you jump directly to the start of the next or previous method.
category:
navigation
tags:
#navigation
#motions
#normal-mode
#editing
How do I run a single normal-mode command without leaving insert mode?
While typing in insert mode, you sometimes need to do a quick normal-mode action — center the screen, jump to a mark, or delete a word backward.
category:
editing
tags:
#insert-mode
#normal-mode
#editing
#motions
How do I move the cursor to the other end of a Visual selection in Vim?
When you make a Visual selection in Vim, the cursor sits at one end while the other end is anchored.
category:
visual-mode
tags:
#visual-mode
#editing
#navigation
#motions
How do I progressively expand or contract a visual selection by text objects?
In visual mode, repeating text object motions progressively expands the selection.
category:
visual-mode
tags:
#visual-mode
#text-objects
#selection
#motions
How do I navigate by sentences, paragraphs, and sections in Vim?
Vim provides structural navigation motions that move by sentences, paragraphs, and sections.
category:
navigation
tags:
#navigation
#motions
#sentence
#paragraph
What is the difference between word and WORD motions in Vim?
Vim distinguishes between "words" (sequences of keyword characters) and "WORDS" (sequences of non-blank characters).
category:
navigation
tags:
#navigation
#motions
#word
#word-motion
How do I navigate through wrapped lines visually instead of by actual lines?
When wrap is enabled, long lines wrap across multiple screen lines.
category:
navigation
tags:
#navigation
#motions
#wrapped-lines
#display
How do I use count prefixes to amplify motions and operators in Vim?
Almost every Vim motion and operator accepts a numeric count prefix that repeats or amplifies the action.
category:
navigation
tags:
#navigation
#motions
#count
#operators
What is the difference between 0 and ^ for moving to the beginning of a line?
Vim has two distinct motions for moving to the start of a line: 0 goes to column 1 (the absolute start), while ^ goes to the first non-blank character.
category:
navigation
tags:
#navigation
#motions
#line-navigation
#indentation
What is the difference between backtick and apostrophe when jumping to marks?
Vim has two ways to jump to marks: backtick (` `) jumps to the exact line AND column, while apostrophe (') jumps to the line only, positioning the cursor at the
category:
navigation
tags:
#navigation
#marks
#positioning
#motions
How do I jump between method or function definitions in Vim?
The [m and ]m motions jump to the start of method/function definitions in languages with brace-delimited blocks.
category:
navigation
tags:
#navigation
#motions
#methods
#code-navigation
How do I repeat or reverse inline character search with f, t, ; and , in Vim?
The f, F, t, and T motions search for a character on the current line.
category:
navigation
tags:
#navigation
#motions
#find
#inline-search
How do I jump back to locations where I previously made edits?
Vim tracks every position where you made a change in the changelist.
category:
navigation
tags:
#navigation
#editing
#normal-mode
#motions
How do I move forward or backward by sentence in Vim?
The ) and ( motions move by sentence boundaries.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I move the cursor to the last non-blank character on the current line?
g moves the cursor to the last non-blank character of the current line — skipping trailing spaces and tabs.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I scroll the view left or right without moving the cursor in Vim?
When a line is longer than the window width and wrap is off, Vim can display only part of it.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I jump to the middle of a line in Vim?
The gM command moves the cursor to the horizontal middle of the current line, regardless of how long the line is.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I reuse the last search pattern without retyping it in Vim?
In Vim, pressing // (two forward slashes) in Normal mode repeats the last search pattern.
category:
search
tags:
#search
#normal-mode
#motions
How do I visually select an entire sentence in Vim?
The vas command visually selects the current sentence, including surrounding whitespace.
category:
visual-mode
tags:
#visual-mode
#text-objects
#motions