Carlosedp
Carlosedp

Reputation: 1951

Prevent vim from switching to a specific window

I've been using VIM with NERDTree and MiniBuffExplorer. I mapped my TAB key to cycle between windows(C-W)w, usually I have the MiniBuffm NERDTree and a editing window open but I would like to prevent VIM from switching to the MiniBuffExplorer window cycling between the NT and my editing buffer.

Is this possible?

Upvotes: 2

Views: 316

Answers (1)

Herbert Sitz
Herbert Sitz

Reputation: 22226

One method is to set up an autocommand for the buffer you don't want to enter:

au BufEnter NameOfSkipBuffer :wincmd j

After that the command :wincmd j will be automatically issued whenever the buffer you have indicated is entered. That may not be the command you want; you can change it to whatever works for your situation.

Note that you will not be able to enter the buffer yourself even when you are trying to get into it. E.g., if it is in a split window and you mouse click on the buffer's window you will find that the cursor moves into the window below it (with my command above).

To change this you would need to remove the BufEnter autocommand:

au! BufEnter NameOfSkipBuffer

Depending on your needs this method may or may not work, but it's nice and simple.

Upvotes: 3

Related Questions