Ⅰ. 插件描述
An only slightly smarter :onlyⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'sodapopcan/if-i-only'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'sodapopcan/if-i-only'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'sodapopcan/if-i-only'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/sodapopcan/vim-ifionly
Ⅳ. 文档说明
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 was calling :only like crazy, only to have to bring back my
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](https://www.youtube.com/watch?v=4uFwM9Bnp_I).