commit 5b6db3a98dd253653958b1718b29f01b00a50e55
parent 97f1f25b85ddf74d348db78597d9e63da5a38c13
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Mon, 1 Oct 2018 22:44:40 +0200
Vim function toggle relative-absolute numbering
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/vim/commands.vimrc b/vim/commands.vimrc
@@ -10,6 +10,8 @@ command! Diffc w !git diff % -
command! Fuckwindows %s/
//g
command! Hexedit %!xxd
command! Unhex %!xxd -r
+
+" Functions
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
@@ -19,6 +21,15 @@ function! InsertTabWrapper()
endif
endfunction
+function! ToggleNumber()
+ if(&relativenumber == 1)
+ set norelativenumber
+ set number
+ else
+ set relativenumber
+ endif
+endfunc
+
" Fat finger fixes/convenience abbreviations
cnoreabbrev W! w!
cnoreabbrev Q! q!
diff --git a/vim/map.vimrc b/vim/map.vimrc
@@ -61,6 +61,9 @@ nnoremap <leader>hs :set list!<cr>
nnoremap <leader>mm :<C-u>marks<CR>:normal! `
nnoremap <leader>ml :<C-u>marks a-z<CR>:normal! `
+" Switch between relative and absolute line num
+nnoremap <leader>n :call ToggleNumber()<CR>
+
" Map '0' to act as '^' on first press and '0' on second
nnoremap <expr> <silent> 0 col('.') == match(getline('.'),'\S')+1 ? '0' : '^'