sponsor Vim development Vim logo Vim Book Ad

If I Only... : An only slightly smarter :only

 script karma  Rating 51/16, Downloaded by 835  Comments, bugs, improvements  Vim wiki

created by
Andrew Haust
 
script type
utility
 
description
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.

I made this because my default vim state is to have two buffers open, side-by-side. Sometimes I'll find myself in a position where git status, the quickfix window, and sometimes even NERDTree--(or, ahem the twiggy window) are all open and I want to quickly get back to my default state in one or two keystokes.

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. For example:

let g:ifionly_filetypes = ['nerdtree']

Development is done at https://github.com/sodapopcan/vim-ifionly

If I Only...'s namesake is a song by Toronto, ON band Do Make Say Think.
 
install details
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-ifionly.zip 1.1 2019-06-06 7.0 Andrew Haust Bring back recently closed splits
ifionly.zip 1.0 2018-01-17 7.0 Andrew Haust Initial upload
ip used for rating: 3.16.66.206

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 the maillist. Help Bram help Uganda.
   
Vim at Github