sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #58: how to avoid obliterating window layout

 tip karma   Rating 4/5, Viewed by 1343 

created:   March 28, 2001 8:00      complexity:   intermediate
author:   scotch      as of Vim:   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 accidently
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>

references:

:help :only
:help CTRL-W_o

That is all.
Scott

 rate this tip  Life Changing Helpful Unfulfilling 

<<previous buffer | Applying substitutes to a visual block >>

Additional Notes

[email protected], January 16, 2002 15:15
See tip vimtip #199 for a way to map these keys to a maximize window - return to split structure function.
[email protected], December 4, 2003 12:18
Another solution is given by ZoomWin (vimscript#508) which makes <c-w>o
toggle between the multi-window display and a single window.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
    stats
Sponsored by Web Concept Group Inc. SourceForge.net Logo