Hey all,

I am wondering if there is any key-binding or script to let me go
back/forward between the new position to the original one?

Saying, I am editing the text in the middle of the buffer and wanna go
back to the first line to see what the title is. After I press "gg" to
the first line, I wanna know how to jump back to the original position
to keep going my editing.

I know the "mark"-m works if I make a mark before I jump to somewhere in
the same buffer. But if I have several files to edit, how to go
back/forward between those files? It seems "mark" only works in single
buffer. I have googled for many days, but unfortunately, no answer for
this so far. Does anybody here have good solution?

Thank you in advance.

Joseph



CTRL-O works a treat, even across old files!

See:

:help jump-motions

Hope this helps;
No need for a script... check out ":help jumps"


There are, as usual with vim, multiple ways to attack the problem.

For simple "go back to where I was before I jumped somewhere
else", you can use ``  (that's "back-tick back-tick").

In addition, you can use ^I and ^O to go forward and backward in
your jump-list.  Vim maintains a list of "large jumps" ("fixed at
100" according to ":help jumplist" where you'll find further info).


If you are inserting some text, hit <esc> and then "gg" to go and
check something at the top of your file, you can then use

        gi

to resume in insert mode where you last left off.  More info on
that can be found at ":help gi"

For yet more options, vim drops marks automatically where you
last inserted (the "^" mark) and where you last made a change was
made (the "." mark) so you can use

        `.

to go the last place you made a change or

        `^

to go the the last place you were in insert mode.

        :help `.
        :help `^

should give you some leads on that one.

Hope this gives you some options for how to do what you want.

-tim


'우분투' 카테고리의 다른 글

제로보드4 세팅 관련 (PHP, UTF8)  (2) 2011.06.22
VIM UTF8, EUC-KR 자동 설정  (0) 2011.06.22
공짜 무료 C/C++ 컴파일러들 무료프로그램  (0) 2011.05.15
APM 한방 셋업  (0) 2011.05.12
링크 (심볼릭, 하드)  (0) 2011.05.10

설정

트랙백

댓글