From 135bf16284e8a5e166462492509b9bf4451f3bca Mon Sep 17 00:00:00 2001 From: Dylan Chong Date: Sun, 17 Jun 2018 22:07:34 +1200 Subject: [PATCH 1/3] Add instructions to README to override wq/q/q! (issue #37) --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 3116aa9..99077e1 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,33 @@ moves your original statusline content to tabline. Wintabs has a handful of configuration options, see `:help wintabs-options` for details. +## Overriding wq/q/q! + +If you want `wq`, `q`, and `q!` to close the current buffer, without closing the +other buffers, add this to your `.vimrc`: + +```vim +" Function to replace built in commands +" Taken from: http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev +function! CommandCabbr(abbreviation, expansion) + execute 'cabbr ' + \. a:abbreviation + \. ' =getcmdpos() == 1 && getcmdtype() == ":" ? "' + \. a:expansion + \. '" : "' + \. a:abbreviation + \. '"' +endfunction + +function! SaveAndCloseCurrentBuffer() + :w + call wintabs#close() +endfunction +call CommandCabbr('q', 'call wintabs#close()') +call CommandCabbr('q!', 'call wintabs#close()') " NOTE: Still asks for confirmation if not saved +call CommandCabbr('wq', 'call SaveAndCloseCurrentBuffer()') +``` + # FAQ Q: Does wintabs support Powerline fonts? From d8af7333bef6225b95881792000675400d770b24 Mon Sep 17 00:00:00 2001 From: Dylan Chong Date: Mon, 18 Jun 2018 09:22:34 +1200 Subject: [PATCH 2/3] Added commands to read me to automatically close vim --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 99077e1..98ddca9 100644 --- a/README.md +++ b/README.md @@ -112,9 +112,14 @@ function! SaveAndCloseCurrentBuffer() :w call wintabs#close() endfunction + call CommandCabbr('q', 'call wintabs#close()') call CommandCabbr('q!', 'call wintabs#close()') " NOTE: Still asks for confirmation if not saved call CommandCabbr('wq', 'call SaveAndCloseCurrentBuffer()') + +" Automatically close tabs to make wq/q/q! behave more normally +let g:wintabs_autoclose_vim = 1 +let g:wintabs_autoclose_vimtab = 1 ``` # FAQ From 60f651b9f981f3ae9baa1d1a569a1e5ca94a3300 Mon Sep 17 00:00:00 2001 From: Dylan Chong Date: Mon, 18 Jun 2018 09:44:59 +1200 Subject: [PATCH 3/3] Remember to add the last auto close option (fixes last commit) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 98ddca9..820bf79 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ call CommandCabbr('wq', 'call SaveAndCloseCurrentBuffer()') " Automatically close tabs to make wq/q/q! behave more normally let g:wintabs_autoclose_vim = 1 let g:wintabs_autoclose_vimtab = 1 +let g:wintabs_autoclose = 2 ``` # FAQ