John
John

Reputation: 2922

How can I toggle line numbers on all windows in the current tab in vim, except NerdTree?

In my .vimrc, I want a key combination that will toggle line numbers on all windows in the current tab I'm looking at except for the:

The Tagbar I'm using is this: https://github.com/preservim/tagbar

If I simply use: :set number and :set nonumber, that only effects the active window, so if my active window happens to be NERDTree, my shortcut will enable line numbers on NERDTree, which is not what I want.

Also, if I have multiple windows open, I want it to enable/disable numbers on all my windows - not just the active one, but ignore the NERDTree window, and the Tagbar window.

Is this possible?

Upvotes: 0

Views: 299

Answers (1)

John
John

Reputation: 2922

Found it:

windo if &filetype != 'nerdtree' && &filetype != 'tagbar' | set number | set relativenumber | endif

the | set relativenumber is only if you want that as well, but demonstrates how to set multiple options.

Upvotes: 1

Related Questions