From 55be0fb188ad016d33b2addf637ba512687b2c12 Mon Sep 17 00:00:00 2001 From: Robert Cranston <rcrnstn@rcrnstn.net> Date: Sun, 5 Nov 2017 06:49:43 +0100 Subject: [PATCH] Add `N` to toggle both `{relative,}number` --- plugin/unimpaired.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/unimpaired.vim b/plugin/unimpaired.vim index b5f46ba..88ceb60 100644 --- a/plugin/unimpaired.vim +++ b/plugin/unimpaired.vim @@ -228,6 +228,10 @@ function! s:cursor_options() abort return &cursorline && &cursorcolumn ? 'nocursorline nocursorcolumn' : 'cursorline cursorcolumn' endfunction +function! s:number_options() abort + return &number && &relativenumber ? 'nonumber norelativenumber' : 'number relativenumber' +endfunction + function! s:option_map(letter, option, mode) abort call s:map('n', '[o'.a:letter, ':'.a:mode.' '.a:option.'<C-R>=<SID>statusbump()<CR><CR>') call s:map('n', ']o'.a:letter, ':'.a:mode.' no'.a:option.'<C-R>=<SID>statusbump()<CR><CR>') @@ -247,6 +251,9 @@ call s:option_map('i', 'ignorecase', 'set') call s:option_map('l', 'list', 'setlocal') call s:option_map('n', 'number', 'setlocal') call s:option_map('r', 'relativenumber', 'setlocal') +call s:map('n', '[oN', ':set number relativenumber<CR>') +call s:map('n', ']oN', ':set nonumber norelativenumber<CR>') +call s:map('n', '=oN', ':set <C-R>=<SID>number_options()<CR><CR>') call s:option_map('s', 'spell', 'setlocal') call s:option_map('w', 'wrap', 'setlocal') call s:map('n', '[ov', ':set virtualedit+=all<CR>') -- 2.17.1