Created
June 28, 2012 15:53
-
-
Save dlo/3012145 to your computer and use it in GitHub Desktop.
Relative Line Numbers in Vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set rnu | |
au BufEnter * :set rnu | |
au BufLeave * :set nu | |
au WinEnter * :set rnu | |
au WinLeave * :set nu | |
au InsertEnter * :set nu | |
au InsertLeave * :set rnu | |
au FocusLost * :set nu | |
au FocusGained * :set rnu |
@brianbaligad is right. My current setup is:
set number
set relativenumber
augroup linenumbers
autocmd!
autocmd BufEnter * :set relativenumber
autocmd BufLeave * :set number norelativenumber
autocmd WinEnter * :set relativenumber
autocmd WinLeave * :set number norelativenumber
autocmd InsertEnter * :set number norelativenumber
autocmd InsertLeave * :set relativenumber
autocmd FocusLost * :set number norelativenumber
autocmd FocusGained * :set relativenumber
augroup END
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vim 7.4 introduced a hybrid mode that shows both relative number and the line number you're currently on. Now that either mode is non-exclusive I think you'll need to disable the current mode to toggle.