| View previous topic :: View next topic |
| Author |
Message |
Charles M Guest
|
Posted: Sun Nov 16, 2008 11:24 pm Post subject: Move to last position |
|
|
Is there a command to move to your last position in vim?
For instance, I'm editing and maybe hit a key by mistake
that takes me far away from my cursor position. I don't
know how I got here and I don't have any marks set up.
How to I get back to my last cursor position?
CMM |
|
| |
|
Back to top |
Rouben Rostamian Guest
|
Posted: Mon Nov 17, 2008 12:20 am Post subject: Re: Move to last position |
|
|
In article <slrngi0lpi.11o.CharlesM@194.sub-70-194-175.myvzw.com>,
Charles M <CharlesM@194.sub-70-194-175.myvzw.com> wrote:
| Quote: | Is there a command to move to your last position in vim?
For instance, I'm editing and maybe hit a key by mistake
that takes me far away from my cursor position. I don't
know how I got here and I don't have any marks set up.
How to I get back to my last cursor position?
|
The key sequence `` (two single backward quotes)
takes you to the position you jumped from.
The key sequence '' (two single forward quotes)
takes you to the line you jumped from.
--
Rouben Rostamian |
|
| |
|
Back to top |
Charles M Guest
|
Posted: Mon Nov 17, 2008 4:27 am Post subject: Re: Move to last position |
|
|
On 2008-11-16, Rouben Rostamian <rostamia@umbc.edu> wrote:
| Quote: | In article <slrngi0lpi.11o.CharlesM@194.sub-70-194-175.myvzw.com>,
Charles M <CharlesM@194.sub-70-194-175.myvzw.com> wrote:
Is there a command to move to your last position in vim?
For instance, I'm editing and maybe hit a key by mistake
that takes me far away from my cursor position. I don't
know how I got here and I don't have any marks set up.
How to I get back to my last cursor position?
The key sequence `` (two single backward quotes)
takes you to the position you jumped from.
The key sequence '' (two single forward quotes)
takes you to the line you jumped from.
|
`` Doesn't do that, although I've read in a number of places that it
should. If I place the cursot at a middle spot on a document (right
before a word so I know that exact position of the cursor) then issue
a movement command (say, :$ go to end of file) and then type `` ,I go
to the top of the file NOT where I was. Same with '' . |
|
| |
|
Back to top |
Rouben Rostamian Guest
|
Posted: Mon Nov 17, 2008 9:06 am Post subject: Re: Move to last position |
|
|
In article <slrngi17hl.5je.CharlesM@Macintosh.local>,
Charles M <CharlesM@Macintosh.local> wrote:
| Quote: |
The key sequence `` (two single backward quotes)
takes you to the position you jumped from.
The key sequence '' (two single forward quotes)
takes you to the line you jumped from.
`` Doesn't do that, although I've read in a number of places that it
should. If I place the cursot at a middle spot on a document (right
before a word so I know that exact position of the cursor) then issue a
movement command (say, :$ go to end of file) and then type `` ,I go to
the top of the file NOT where I was. Same with '' .
|
The `` and '' commands you back to the previous position after a
"jump". Not all movements are jumps. This is from vim's help:
A "jump" is one of the following commands: "'", "`", "G",
"/", "?", "n", "N", "%", "(", ")", "[[", "]]", "{", "}", ":s",
":tag", "L", "M", "H" and the commands that start editing a new
file. If you make the cursor "jump" with one of these commands,
the position of the cursor before the jump is remembered.
You can return to that position with the "''" and "``" command,
unless the line containing that position was changed or deleted.
--
Rouben Rostamian |
|
| |
|
Back to top |
Kenny McCormack Guest
|
Posted: Mon Nov 17, 2008 12:14 pm Post subject: Re: Move to last position |
|
|
In article <gfqs7s$crc$1@linux2.gl.umbc.edu>,
Rouben Rostamian <rostamia@umbc.edu> wrote:
| Quote: | In article <slrngi17hl.5je.CharlesM@Macintosh.local>,
Charles M <CharlesM@Macintosh.local> wrote:
The key sequence `` (two single backward quotes)
takes you to the position you jumped from.
The key sequence '' (two single forward quotes)
takes you to the line you jumped from.
`` Doesn't do that, although I've read in a number of places that it
should. If I place the cursot at a middle spot on a document (right
before a word so I know that exact position of the cursor) then issue a
movement command (say, :$ go to end of file) and then type `` ,I go to
the top of the file NOT where I was. Same with '' .
The `` and '' commands you back to the previous position after a
"jump". Not all movements are jumps. This is from vim's help:
A "jump" is one of the following commands: "'", "`", "G",
"/", "?", "n", "N", "%", "(", ")", "[[", "]]", "{", "}", ":s",
":tag", "L", "M", "H" and the commands that start editing a new
file. If you make the cursor "jump" with one of these commands,
the position of the cursor before the jump is remembered.
You can return to that position with the "''" and "``" command,
unless the line containing that position was changed or deleted.
|
All of which boils down to: It usually works, but it isn't guaranteed.
This agrees with my experience. |
|
| |
|
Back to top |
Cesar Romani Guest
|
Posted: Mon Nov 17, 2008 10:54 pm Post subject: Re: Move to last position |
|
|
Charles M wrote:
| Quote: | Is there a command to move to your last position in vim?
For instance, I'm editing and maybe hit a key by mistake
that takes me far away from my cursor position. I don't
know how I got here and I don't have any marks set up.
How to I get back to my last cursor position?
CMM
|
CTRL-o
see :help CTRL-o
Regards,
CR |
|
| |
|
Back to top |
|