sponsor Vim development Vim logo Vim Book Ad

numbers.vim : plugin for intelligently toggling line numbers.

 script karma  Rating 1/1, Downloaded by 603  Comments, bugs, improvements  Vim wiki

created by
Benedykt Przybyło
script type
Github: https://github.com/b3niup/numbers.vim

numbers.vim is a plugin for intelligently toggling line numbers.  
It is a fork of @myusuf3 plugin.

This plugin alternates between relative (`relativenumber`), absolute (`number`)  
and hidden line numbering for active window depending on the mode you are in.

In `hidden` mode all event-based mode changes are turned off to keep numbers  
hidden untill next `NumbersToggle` or `NumbersEnable` call.

Commands are included for toggling the line numbering method and for enabling and disabling the plugin.

Hiding numbers in plugins and files

If you would like to hide numbers in vim plugins or in files with specified filetype you can set custom g:numbers_exclude list in your .vimrc:

    let g:numbers_exclude = ['nerdtree', 'html']

This example will hide numbers in NERD Tree and all html files.

By default plugin excludes following filetypes:

    let g:numbers_exclude = ['minibufexpl', 'nerdtree', 'unite', 'tagbar', 'startify', 'gundo', 'vimshell', 'w3m']

Be sure to include this superset in your .vimrc if you only would like to extend it.


Once installed, no action is *required* on your part.  
But for convenience, you may want to add mappings in your `.vimrc` for some of the commands, e.g.,

    nnoremap <silent> <F2> :NumbersToggle<CR>

It is though *strongly recommended* to use following mapping:

    inoremap <C-c> <Esc><Esc>

It is a workaround for issue where `InsertLeave` event is not working with Ctrl+c.  
Another way to fix this is add `autocmd CursorMoved * :call NumbersReset()` in `NumbersEnable()` function  
around line 104 in `plugin/numbers.vim`, but personally I do not like idea of calling even such light function with every cursor move.
install details
Using vundle or pathogen for installation is recommended.

For vundle users, add the following to your `.vimrc` and then run a `:BundleInstall`:

    Bundle "b3niup/numbers.vim"

For pathogen users, clone the repo:

    git clone https://github.com/b3niup/numbers.vim.git ~/.vim/bundle/numbers

If you really would like to install plugin manually:

    Download the plugin and paste it into your plugin directory.

Once installed, no action is *required* on your part.  

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
numbers.vim.zip v0.5.0 2014-11-05 7.3 Benedykt Przybyło Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
Vim at Github