Sławosz
Sławosz

Reputation: 11687

Fast switching between two lines in file in vim

sometimes I have to switch between 2 lines. To do this, I have to pass line number. Are there shortcuts to moving between 2 last 'visited' list. Something similar to '. (it moves to last edited line)

Upvotes: 13

Views: 1930

Answers (3)

DigitalRoss
DigitalRoss

Reputation: 146073

Double-backtick or double single-quote will do exactly that

There is a command that will bounce to the last location you jumped away from. If repeated, it will then return to the jump destination you were just on. If repeated further it will bounce you back and forth between the two locations.

The command has two forms:

``

or

''

Upvotes: 17

Dave Kirby
Dave Kirby

Reputation: 26552

ctrl-o and ctrl-i will move backwards and forwards through your history of jump points. A jump point is pretty much any command that moves the cursor more than one line. It will also go back to previous files that were loaded into the current buffer.

See :h jump-motions for more information.

Upvotes: 9

Greg Hewgill
Greg Hewgill

Reputation: 993153

You can use bookmarks, something like ma to mark a bookmark named a, and then 'a to go to it. Naming boomarks a and b for example, you can switch between them with 'a and 'b.

Upvotes: 18

Related Questions