1

I have this in my .vimrc:

nnoremap <C-a> :set relativenumber!<cr>

This toggles the relative number feature only in the current window.

Is it possible to toggle it in all opened windows with one command?

1
  • You might want to add <silent> to your mapping, so that the :set (or :windo) Ex command doesn't appear in the command line when you use it. Note also that the <C-a> keystroke is a pretty useful command (increment number, in your buffer, if you have one under the cursor of the current line), so think twice before shadowing with a mapping of your own. Cheers!
    – filbranden
    Sep 18, 2020 at 13:23

1 Answer 1

5

Yes, using :h :windo:

nnoremap <C-a> :windo set relativenumber!<CR>
2
  • 2
    Thanks. I think <cr> is missing Sep 18, 2020 at 13:19
  • 1
    Yes! Thank you, it's fixed. Sep 18, 2020 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.