Skip to content

sodapopcan/vim-ifionly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

An only slightly smarter :only

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published