The text object of Vim is made up of two characters, and the first character is always i
or a
. In general, text objects that start with the text i
selected inside the delimiter, and the a
text object that begins with the selection, selects the entire text, including the delimiter. In order to facilitate memory, you can think of it i
as "inside" and think of it a
as "around" or "all". Vim's text object is mainly used to enlarge the selection, and it will be extremely powerful to combine it with visual mode or surround, and some common text objects are listed below.
Text Object |
Select Area |
a) or AB |
Pair of parentheses |
i) or IB |
Inside parentheses |
A} or AB |
A pair of curly braces |
i} or IB |
Curly braces Inside |
At |
A pair of XML tags |
It |
Inside the XML tag |
Aw |
Current Word and a space |
Iw |
Current word |
AW |
Current string and a space |
IW |
Current string |
As |
Current sentence and a space |
Is |
Current sentence |
Ap |
Current paragraph and a blank line |
Ip |
Current paragraph |
The text object can also be combined with the corresponding action, such as d delete, y copy.
Vim's text object