How do you set a window-local option (number
) in literally every window/buffer?
I was to bind <leader>t
to toggle the number
option in every buffer, using a global variable g:linum_status
as the source of truth for whether line numbers should be active or not.
Basically, I'm trying to figure out how to make number
act like a global option, even though it's window-local.
I have the following options set initially
let g:linum_status = 0
set nonumber
and had the following (broken) function ToggleLinum
function! ToggleLinum()
if g:linum_status
bufdo execute "set nonumber"
let g:linum_status = 0
else
bufdo execute "set number"
let g:linum_status = 1
endif
endfunction
This function, however, only toggles the number
option in the current buffer.
I tried switching bufdo
to windo
, which is a little better. Now all of the windows in the focused tab switch, which is actually fairly intuitive.
Still though, is there a way to make flip number
on or off for "every" buffer, possibly exempting things like netrw file exploring buffers.