Vim Tips Wiki
Tip 58 Printable Monobook Previous Next

created March 28, 2001 · complexity intermediate · author scotch · version 5.7

If you take the time to lay out several windows with Vim (especially vertically in version 6), you may be bummed when you hit an errant key and find that all but what one window disappears.

What happens: while navigating between windows, you hit <C-W>j, <C-W>k, etc. At some point you accidentally hit <C-W> but then don't follow with a window command.

Now hitting 'o' to start insert mode issues a command equivalent to :only, and closes all windows execept for the one you are in (unless some windows have unsaved changes in them).

How to avoid this: petition the vim-dev mailing list about how :only is sufficient for the infrequenty use this might get (j/k).

Really: use mapping to disable the <C-W>o functionality; put this in your vimrc

nnoremap <C-W>O :echo "sucker"<CR>
nnoremap <C-W>o :echo "sucker"<CR>
nnoremap <C-W><C-O> :echo "sucker"<CR>



See tip VimTip199 for a way to map these keys to a maximize window - return to split structure function.

Another solution is given by ZoomWin which makes <c-w>o toggle between the multi-window display and a single window.