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.
| Key | Object |
|---|---|
m i w / m a w | The word under the cursor / with the space beside it |
m i W / m a W | The WORD, everything between whitespace / with the space beside it |
m i p / m a p | The 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 m | Inside / around the closest enclosing pair of any of those kinds |
m i f / m a f | Inside / around the enclosing function |
m i t / m a t | Inside / around the enclosing type, such as a class or struct |
m i a / m a a | Inside / around the enclosing argument or parameter |
Examples:
| Keys | Result |
|---|---|
m i w c | Change the word under the cursor |
m a ( d | Delete a parenthesised group with its parentheses |
m i p d | Delete the paragraph’s lines |
m i " y | Yank the text inside the quotes |
m a f | Select 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 pselects 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, som i p dremoves its lines andxextends 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.