diff --git a/autoload/nvim-maximize-window-toggle.vim b/autoload/nvim-maximize-window-toggle.vim new file mode 100644 index 0000000..e284ee3 --- /dev/null +++ b/autoload/nvim-maximize-window-toggle.vim @@ -0,0 +1,28 @@ +"" +" @public +" If the current tab page has more than one window, +" opens the current buffer alone in a new tab. +" Calling this function again in the new window will +" close the tab and go back to the original window +"" +function! nvim-maximize-window-toggle#ToggleOnly() + if winnr("$") > 1 + " There are more than one window in this tab + if exists("b:maximized_window_id") + call win_gotoid(b:maximized_window_id) + else + let b:origin_window_id = win_getid() + tab sp + let b:maximized_window_id = win_getid() + endif + else + " This is the only window in this tab + if exists("b:origin_window_id") + let l:origin_window_id = b:origin_window_id + tabclose + call win_gotoid(l:origin_window_id) + unlet b:maximized_window_id + unlet b:origin_window_id + endif + endif +endfunction diff --git a/doc/nvim-maximize-window-toggle.txt b/doc/nvim-maximize-window-toggle.txt new file mode 100644 index 0000000..8f1b872 --- /dev/null +++ b/doc/nvim-maximize-window-toggle.txt @@ -0,0 +1,15 @@ +*nvim-maximize-window-toggle.txt* + *nvim-maximize-window-toggle* + +============================================================================== +CONTENTS *nvim-maximize-window-toggle-contents* + 1. Commands...........................|nvim-maximize-window-toggle-commands| + +============================================================================== +COMMANDS *nvim-maximize-window-toggle-commands* + +:ToggleOnly *:ToggleOnly* + Maximize the current buffer as a toggle + + +vim:tw=78:ts=8:ft=help:norl: diff --git a/plugin/nvim-maximize-window-toggle.vim b/plugin/nvim-maximize-window-toggle.vim new file mode 100644 index 0000000..c591721 --- /dev/null +++ b/plugin/nvim-maximize-window-toggle.vim @@ -0,0 +1,4 @@ +"" +" Maximize the current buffer as a toggle +"" +command! ToggleOnly call nvim-maximize-window-toggle#ToggleOnly()