Last active
October 12, 2015 02:37
-
-
Save tacahiroy/3958470 to your computer and use it in GitHub Desktop.
a function to show/hide line number for Vim
This file contains hidden or 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
" show/hide line number wisely: this needs Vim 7.3 or above | |
function! s:toggle_line_number() | |
let NU = 'nu' | |
let RNU = 'rnu' | |
if &nu || &rnu | |
" to be off | |
let b:prev = { 'nu': &nu, 'rnu': &rnu } | |
let &nu = 0 | |
let &rnu = 0 | |
else | |
" restore previous setting | |
let &nu = get(b:prev, 'nu', 1) | |
let &rnu = get(b:prev, 'rnu', 1) | |
endif | |
endfunction | |
nnoremap <silent> <Leader>tn :<C-u>silent call <SID>toggle_line_number()<Cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment