How to select the last inserted text in vim

11

7

How to select the last inserted text in vim? For example I want to be able to type a text, exit the insert mode, select what I have just inserted, and change it to uppercase.

Note: I do not consider Caps Lock a solution here.

crenate

Posted 2012-01-26T10:32:22.220

Reputation: 245

Answers

17

You can use

v`[

to select the last insert if you are still at the correct cursor position.

`[

jumps to the beginning of your last insert,

`]

jumps to the end of the last insert respectively. So to be independent of your current cursor position, you'd type

`[v`]~

to toggle the capitalization of your last insert.

barbaz

Posted 2012-01-26T10:32:22.220

Reputation: 2 696

3An alternative to v ~ is gU and gu to capitalize/lowercase the next move. – tidbeck – 2012-01-26T13:43:05.067