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?

  • 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 at 13:23
5

Yes, using :h :windo:

nnoremap <C-a> :windo set relativenumber!<CR>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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