lastpos.vim : Last position jump improved for Easy Vim
script karma |
Rating 7/4,
Downloaded by 1165 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Andy Wokula |
|
script type |
utility |
|
description |
With Easy Vim [1], the code to perform a last position jump [2] can't restore a cursor position beyond EOL, because the jump will be executed in Normal mode [3]. The result in this case is a by-one error [4], so most people [5] won't find that annoying ...
The good news is that Vim seems to store a correct value in the viminfo file -- one solution is to restore the last position while in Insert mode, which is what the plugin does.
Easy Vim actually is not required, the plugin will also work with a normal setup, or when you use :startinsert in the vimrc to merely start up in Insert mode.
The code is slightly more cautious than the original: the cursor won't be moved if something else already moved it, or if the buffer is special (help buffer, etc.). Furthermore, to fix [6] a related case [7], the BufWinEnter autocommand is used instead of BufReadPost.
This lengthy description applies for a rather short piece of code.
[1] :help 'insertmode' or :help -y
[2] :h last-position-jump
[3] explanation http://groups.google.com/group/vim_use/msg/c571f994f211f8fe
[4] the position is almost right, no issue for Bram: http://groups.google.com/group/vim_dev/msg/fbcffe406ff01b7f
[5] especially of the few Easy vimmers
[6] not sure if "modify" is the better word as what follows is probably not a bug
[7] Cursor column not remembered ... http://groups.google.com/group/vim_dev/msg/b3512cecaab3e0b1
|
|
install details |
Drop the file into your plugin folder, restart Vim.
For newbies: this folder could be ~\vimfiles\plugin -- replace '~\vimfiles' with the first entry of your 'runtimepath'.
If you are using the example vimrc :help vimrc_example.vim, you may have
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
in your vimrc – make sure to remove this old code. |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 142.132.191.50
|