lastpos.vim


Ⅰ. 插件描述

Last position jump improved for Easy Vim

Ⅱ. 基本信息

创建日期:  2010-04-15
使用用户:  74
Github星:  2
插件作者:  Andy Wokula

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin '/lastpos-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle '/lastpos-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug '/lastpos-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/vim-scripts/lastpos.vim

Ⅳ. 文档说明

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

添加新评论