Friday, September 30, 2011

Vim's text objects

Let's say I have this line in a file:"some boring message")
and I want to change it to:"request served")
For a long time I did it this way:
1. keep the cursor on 's' of 'some'
2. type ct" (which means change till (the first) " character)
3. type request served.

Recently I figured there's an easier/faster way:
1. keep the cursor anywhere inside the "some boring message" string
2. type ci" (which means change inside quotes)
3. type request served.

Like every Vim feature, this is just one among a dozen or so possible selections.  Check out text objects section in Vim manual.

No comments:

Post a Comment