 | | From: | mynameisnobodyalso at yahoo.com | | Subject: | vi/vim how to continue editing from last position | | Date: | 15 Jan 2005 10:02:25 -0800 |
|
|
 | The vim I'm using always puts the cursor at the beginning of the file when I open it. I'd like it to be placed at the line where I last was editing. Is there a simple way to set this up?
|
|
 | | From: | Christian Schneider | | Subject: | Re: vi/vim how to continue editing from last position | | Date: | Sat, 15 Jan 2005 19:16:52 +0100 |
|
|
 | Thus spake mynameisnobodyalso@yahoo.com (mynameisnobodyalso@yahoo.com): > The vim I'm using always puts the cursor at the beginning of the file > when I open it. I'd like it to be placed at the line where I last was > editing. Is there a simple way to set this up?
Sure. Read
|
|
 | | From: | mark | | Subject: | Re: vi/vim how to continue editing from last position | | Date: | Sun, 16 Jan 2005 07:53:16 +1000 |
|
|
 | On Sat, 15 Jan 2005 19:16:52 +0100, Christian Schneider wrote: > Thus spake mynameisnobodyalso@yahoo.com (mynameisnobodyalso@yahoo.com): >> The vim I'm using always puts the cursor at the beginning of the file >> when I open it. I'd like it to be placed at the line where I last was >> editing. Is there a simple way to set this up? > > Sure. Read
Alternatively, just put this as the first line in your ~/.vimrc:
so $VIMRUNTIME/vimrc_example.vim
|
|
 | | From: | Christian Schneider | | Subject: | Re: vi/vim how to continue editing from last position | | Date: | Sun, 16 Jan 2005 00:12:02 +0100 |
|
|
 | Thus spake mark (mark@nospam.org): > On Sat, 15 Jan 2005 19:16:52 +0100, Christian Schneider wrote: >> Thus spake mynameisnobodyalso@yahoo.com (mynameisnobodyalso@yahoo.com): >>> The vim I'm using always puts the cursor at the beginning of the file >>> when I open it. I'd like it to be placed at the line where I last was >>> editing. Is there a simple way to set this up? >> >> Sure. Read > > Alternatively, just put this as the first line in your ~/.vimrc: > > so $VIMRUNTIME/vimrc_example.vim
Why? Its not necessary to source the complete $VIMRUNTIME/vimrc_example.vim. #v+ " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif #v- Thats all.
|
|