5 ms·
'i' and 'a' (mnemonic: the 'a' grabs all of something (and its white space) as opposed to 'i' which grabs the inner part) as modifiers for 'c', 'd', 'y', and 'v
by telemachos 16y ago
'i' and 'a' (mnemonic: the 'a' grabs all of something (and its white space) as opposed to 'i' which grabs the inner part) as modifiers for 'c', 'd', 'y', and 'v' can be very useful, but I don't see them talked about much in most tutorials.
See :help motion.txt - they're in section 6. Text Object Selection. Also, just play around with them a little. For example:
<p>This is a tes|t. Do not be alarmed.</p>
If that's your text, and the cursor is at the pipe:
ciw # remove all of 'test', enter insert mode
caw # remove the word 'test' and preceding space, enter insert mode
vit # visually select all the text within the <p> tags
vat # visually select the whole <p> element
- llimllib 16y agoand diw and daw delete the whole word, gUiw uppercases the whole word, and ... The composability of vim motion commands is what keeps me using it.
- _pi 16y agoHmm for some reason my motions don't work with [ { ( or b/B. I can't seem to find a reason for this. " works though. Edit: seems actual jump selection can be finicky.