Vim Recall繁體中文

Exchange current and previous selection

gv

Example

Visual 0 / 1
one two
three four
five six
Cursor on line 2, column 3 · Character selection

Exchange current and previous selection.

Before & after
Before
one two
three four
five six
Cursor on line 2, column 3 · Character selection
After
one two
three four
five six
Cursor on line 2, column 1 · Line selection

Start in Visual mode. Prepare a previous linewise Visual area covering the first two lines with Vj then Esc, then a current characterwise area with vll. gv exchanges the current and previous areas.

Details & Vim help

Example replayed in Vim

Exchange current and previous selection. Use in Visual mode. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative.