Ⅰ. 插件描述
Undo a :quit -- reopen the last window you closedⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'andrewradev/undoquit-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'andrewradev/undoquit-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'andrewradev/undoquit-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/andrewradev/undoquit.vim
Ⅳ. 文档说明
This plugin attempts to solve the issue of quitting a window, and then realizing you actually need it moments later. It simply lets you "undo" the quit, similar to the way you would restore a just-closed tab in your browser.
For a visual demo, there's a screencast on youtube
Requirements
Requires Vim at version 7.4 or above.
Usage
Whenever you execute a :quit on a window, that window's position is stored in a stack. Pressing <c-w>u (or executing the :Undoquit command) is going to "undo" that quit, restoring the window to its original position.
Note that this only works on buffers that are "listed", so it won't restore the quickfix window or the NERDTree, but it's assumed that you don't really need this functionality for these kinds of buffers.
Use the g:undoquit_mapping variable to set the mapping for the action. Example:
let g:undoquit_mapping = '_u'Set the variable to an empty string to avoid setting a mapping at all.
Issues
Internally, the plugin listens for the QuitPre event and does some window-hopping to establish the position of the current window. If you notice any odd behaviour when closing windows, like the wrong window gets closed or something, it may be a bug in this plugin. Please disable it and try again, and if the plugin is faulty, please open an issue on the github bugtracker
A known problem is that the plugin doesn't work for <c-w>c, since that mapping doesn't seem to throw a QuitPre autocommand. If you use it, you could make it work by calling the undoquit "save history" function manually:
nnoremap <c-w>c :call undoquit#SaveWindowQuitHistory()<cr><c-w>cContributing
Pull requests are welcome, but take a look at CONTRIBUTING.md first for some guidelines.
