Skip to content

Instantly share code, notes, and snippets.

@tacahiroy
Last active October 12, 2015 02:37
Show Gist options
  • Save tacahiroy/3958470 to your computer and use it in GitHub Desktop.
Save tacahiroy/3958470 to your computer and use it in GitHub Desktop.
a function to show/hide line number for Vim
" 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