User guide / Key bindings

Text objects

Development reference · View source

m i selects inside a text object and m a around it, as in Helix. Every object works at every cursor. The result is left in Select mode, so d, c, y, and p act on it and a motion extends it.

KeyObject
m i w / m a wThe word under the cursor / with the space beside it
m i W / m a WThe WORD, everything between whitespace / with the space beside it
m i p / m a pThe paragraph’s lines / with the blank lines beside them
m i ( / m a (, also [, {, <, ", ', `Inside / around the enclosing pair; closing brackets are aliases
m i m / m a mInside / around the closest enclosing pair of any of those kinds
m i f / m a fInside / around the enclosing function
m i t / m a tInside / around the enclosing type, such as a class or struct
m i a / m a aInside / around the enclosing argument or parameter

Examples:

KeysResult
m i w cChange the word under the cursor
m a ( dDelete a parenthesised group with its parentheses
m i p dDelete the paragraph’s lines
m i " yYank the text inside the quotes
m a fSelect the enclosing function

Words and paragraphs are read from the text alone, so they work in every buffer.

  • A word is a run of letters, digits, and _; a run of punctuation; or a run of whitespace. A WORD is everything between whitespace.
  • Around adds the whitespace after the word, or before it when nothing follows on the line.
  • Neither crosses a line break. A cursor on an empty line has no word.
  • A paragraph is a run of lines holding text, separated by empty or whitespace-only lines. On a blank line, m i p selects the run of blank lines.
  • Around adds the blank lines after the paragraph, or before it at the end of the file.
  • A paragraph is selected as whole lines, like x, so m i p d removes its lines and x extends the selection.

Delimiter pairs resolve through the syntax tree when there is one, which tells a bracket in code from one in a string. Otherwise a balanced text scan answers: in plain text, in languages without a grammar, while a file is still parsing, or when the tree finds no pair (as inside a comment).

  • Brackets nest and may span lines. The scan reaches 65,536 characters on each side of the selection.
  • Quotes pair up from the start of the line, so a quoted string spanning lines is not found by the scan.
  • A backslash-escaped delimiter is text.
  • Asking again with a pair selected grows to the next pair out.
  • In ordinary Markdown prose, the scan is first bounded to the enclosing Markdown syntax node.

Functions, types, and arguments need the syntax tree. Without one they say why and leave the selection alone.