Ⅰ. 插件描述
This Vim plugin only shows relative line numbers when you need them.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'ericbn/vim-relativize'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'ericbn/vim-relativize'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'ericbn/vim-relativize'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/ericbn/vim-relativize
Ⅳ. 文档说明
# relativize.vim
This plugin only shows relative line numbers when you need them: in the current
window, and if you're not in insert mode. Otherwise, it will give you the
absolute numbers. As suggested by [Jeff
Kreeftmeijer](http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement/).
Installation
- Using pathogen.vim:
cd ~/.vim/bundle
git clone git://github.com/ericbn/vim-relativize.git - Using vim-plug:
Plug 'ericbn/vim-relativize'
Configuration
Add one of the following to your .vimrc
depending on the initial look you
want:
Relative line numbers when you need them:
set relativenumber
- Relative numbers when you need them, with the absolute line number in the
current line (requires at least Vim 7.4):
set number relativenumber
- Absolute line numbers all the time (toggle relative numbers when you need
them with:RelativizeToggle
):
set number
- No numbers at all (use the map below to switch numbers from appearing, will
first switch to absolute line numbers):
(nothing)
You can toggle relative line numbers from appearing with :RelativizeToggle
.
To map a key (e.g. F2) to this command, add the following to your.vimrc
:
nnoremap <silent> <F2> :RelativizeToggle<CR>
To map a key (e.g. F3) to switch the numbers from appearing or not
at all, add this to your .vimrc
:
nnoremap <silent> <F3> :let [&number, &relativenumber] =
\ [!&number && (g:relativize_with_number \|\| !g:relativize_enabled),
\ !&relativenumber && g:relativize_enabled]<CR>
Why another 'relativenumber' plugin?
This is a no-nonsense plugin with only 27 lines of code. I believe this is how
a plugin for such a simple feature should be. It is flexible, and plays well
with other plugins without the need for extra configuration options.
If you want a plugin that needs more configuration options, try
numbertoggle,
numbers.vim,
vim-relativity,
vim-autonumber,
RelativeNumberCurrentWindow
or smartnumber.vim.
To have relative line numbering only in operator-pending mode, try
RelOps.
If you want an even simpler plugin, that will only switch between absolute and
relative line numbers on a mapped key or lead shortcut, try
toggle-numbers.vim or
vim-toggle-relative-line-numbers.
License
Copyright © Eric Nielsen. Distributed under the same terms as Vim itself. See:help license
.