Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 2.04 KB

README.markdown

File metadata and controls

60 lines (43 loc) · 2.04 KB

If I Only…

If I Only… is an only slightly smarter :only.

If there are any unmodifiable buffers open (NERDTree, :Gstatus, quickfix window, etc.), close them leaving any modifiable buffers alone. If there are only modifiable splits open, make the current one the only one—i.e., call plain old :only. If you are in an unmodifiable buffer, jump to the first modifiable one (this last point is configurable; see :help ifionly).

If invoking :IfIOnly leaves one buffer, calling it again to bring back any windows that were closed (ie, it acts as a poor man's WinZoom. This is available until quitting Vim.

Usage

There is only one command (:IfIOnly) and one mapping (<C-W>O).

I would suggest using an even simpler mapping. Personally, I use L:

nnoremap L :IfIOnly<CR>

Motivation

My default vim state is to have two modifiable buffers open, side-by-side. Sometimes I'll find myself in a position where the :Gstatus window, the quickfix window, and sometimes even NERDTree—or, ahem twiggy—are all open and I want to quickly get back to my default state in one or two keystokes. For the longest time I would call :only on an artibrary window only to have to bring back the discarded split... hence If I Only…

If this sounds useful to you yet you like to have something like NERDTree open at all times, g:ifionly_filetypes can be set in your vimrc. It takes a list of filetypes to be left alone by this plugin. For example:

let g:ifionly_filetypes = ['nerdtree']

About

Like this plugin? Please star it or vote for it on vim.org! Any feedback is always welcome.

If I Only…'s namesake is a song by Do Make Say Think.