├── .gitignore ├── README.md ├── doc └── maximizer.txt └── plugin └── maximizer.vim /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | doc/tags 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vim-maximizer 2 | ============= 3 | 4 | Maximizes and restores the current window in Vim. 5 | 6 | 7 | Installation 8 | ------------ 9 | 10 | Place in *~/.vim/plugin/maximizer.vim* or in case of Pathogen: 11 | 12 | cd ~/.vim/bundle 13 | git clone https://github.com/szw/vim-maximizer.git 14 | 15 | Please, don't forget to star the repository if you like (and use) the plugin. This will let me know 16 | how many users it has and then how to proceed with further development :). 17 | 18 | 19 | About 20 | ----- 21 | 22 | Maximizer lets you maximize split windows and restore them automatically. It is very useful if you 23 | like to have many split windows per tab. And also, if the text you are working with does not 24 | [_...subscribe to the ridiculous Church of 80-character 25 | Lines..._](http://37signals.com/svn/posts/3250-clarity-over-brevity-in-variable-and-method-names). 26 | It means, while working with Ruby on Rails code. ;) Or just with lengthy HTML files. 27 | 28 | 29 | Usage 30 | ----- 31 | 32 | Maximizer has only one command: 33 | 34 | :MaximizerToggle 35 | 36 | Also the plugin can define some default mappings if the user wants to. By default it maps to `` 37 | in normal, insert, and visual modes. See [Configuration](#configuration) to get some examples. 38 | 39 | When the current window is not in maximized state, Vim-Maximizer saves dimensions and positions of 40 | all windows in the current tab, and then it performs maximization of the active window. The second 41 | time the command is invoked, Maximizer restores all windows to the previously saved positions. 42 | 43 | The toggle command can be invoked with a bang (!): 44 | 45 | :MaximizerToggle! 46 | 47 | The bang version forces the restoration of previously saved state (if any). It can be used in case 48 | you did some changes in the maximized state layout and the current window is not maximized anymore. 49 | Despite that, the bang version force restoration anyway. Notice, the bang version can be set as the 50 | default one in your mappings. 51 | 52 | 53 |
54 | Configuration 55 | ------------- 56 | 57 | Maximizer is extremely handy with command mappings. By default it uses `` like here: 58 | 59 | nnoremap :MaximizerToggle 60 | vnoremap :MaximizerTogglegv 61 | inoremap :MaximizerToggle 62 | 63 | With these mappings you can hit `` any time, not only in normal mode. Other handy situations may 64 | include typing some text while you don't fit the current split window or selecting some long lines 65 | in the visual mode. Just try it yourself. 66 | 67 | Maximizer respects minimal allowed window size, both vertically and horizontally. By default the 68 | minimal window height and width are set to 1. You can change those values by tweaking 69 | `'winminheight'` (`'wmh'`) and `'winminwidth'` (`'wmw'`) settings in your .vimrc. 70 | 71 | 72 | Here are some plugin options: 73 | 74 | 75 | * `maximizer_set_default_mapping` 76 | 77 | Whether Maximizer should set default mappings or not: 78 | 79 | let g:maximizer_set_default_mapping = 1 80 | 81 | 82 | * `maximizer_set_mapping_with_bang` 83 | 84 | Whether Maximizer should set default mappings with banged version or not: 85 | 86 | let g:maximizer_set_mapping_with_bang = 0 87 | 88 | 89 | * `maximizer_default_mapping_key` 90 | 91 | The default mappings key: 92 | 93 | let g:maximizer_default_mapping_key = '' 94 | 95 | 96 | Author and License 97 | ------------------ 98 | 99 | Maximizer was written by Szymon Wrozynski and 100 | [Contributors](https://github.com/szw/vim-maximizer/commits/master). It is licensed under the same 101 | terms as Vim itself. 102 | 103 | Copyright © 2012-2013 Szymon Wrozynski. See `:help license` 104 | -------------------------------------------------------------------------------- /doc/maximizer.txt: -------------------------------------------------------------------------------- 1 | *maximizer.txt* For Vim version 7.3 Last change: 2013-04-08 2 | *maximizer* 3 | 4 | 5 | 6 | 7 | 8 | 9 | Vim-Maximizer version 1.0.4~ 10 | 11 | Maximizes and restores the current window in Vim.~ 12 | 13 | 14 | 15 | 16 | 17 | Copyright (c) 2012-2013 Szymon Wrozynski 18 | 19 | ============================================================================ 20 | Table of Contents 21 | 22 | 1. About.................................................|maximizer-about| 23 | 2. Usage.................................................|maximizer-usage| 24 | 3. Configuration.................................|maximizer-configuration| 25 | 4. Author and License...........................|maximizer-author-license| 26 | 27 | ---------------------------------------------------------------------------- 28 | 1. About *maximizer-about* 29 | 30 | Maximizer lets you maximize split windows and restore them automatically. It 31 | is very useful if you like to have many split windows per tab. And also, if 32 | the text you are working with does not "...subscribe to the ridiculous Church 33 | of 80-character Lines..." 34 | (http://37signals.com/svn/posts/3250-clarity-over-brevity-in-variable-and-method-names) 35 | It means, while working with Ruby on Rails code. ;) Or just with lengthy HTML 36 | files. 37 | 38 | ---------------------------------------------------------------------------- 39 | 2. Usage *maximizer-usage* 40 | 41 | Maximizer has only one command: > 42 | 43 | :MaximizerToggle 44 | < 45 | 46 | Also the plugin can define some default mappings if the user wants to. 47 | By default it maps to in normal, insert, and visual modes. 48 | See |maximizer-configuration| to get some examples. 49 | 50 | When the current window is not in maximized state, Vim-Maximizer saves 51 | dimensions and positions of all windows in the current tab, and then it 52 | performs maximization of the active window. The second time the command is 53 | invoked, Maximizer restores all windows to the previously saved positions. 54 | 55 | The toggle command can be invoked with a bang (!): > 56 | 57 | :MaximizerToggle! 58 | 59 | < 60 | 61 | The bang version forces the restoration of previously saved state (if any). 62 | It can be used in case you did some changes in the maximized state layout and 63 | the current window is not maximized anymore. Despite that, the bang version 64 | force restoration anyway. Notice, the bang version can be set as the default 65 | one in your mappings. 66 | 67 | ---------------------------------------------------------------------------- 68 | 3. Configuration *maximizer-configuration* 69 | 70 | Maximizer is extremely handy with command mappings. By default it uses 71 | like here: > 72 | 73 | nnoremap :MaximizerToggle 74 | vnoremap :MaximizerTogglegv 75 | inoremap :MaximizerToggle 76 | 77 | < 78 | 79 | With these mappings you can hit any time, not only in normal mode. Other 80 | handy situations may include typing some text while you don't fit the current 81 | split window or selecting some long lines in the visual mode. Just try it 82 | yourself. 83 | 84 | Maximizer respects minimal allowed window size, both vertically and 85 | horizontally. By default the minimal window height and width are set to 1. 86 | You can change those values by tweaking |'winminheight'| (|'wmh'|) and 87 | |'winminwidth'| (|'wmw'|) settings in your .vimrc. 88 | 89 | 90 | Here are some plugin options: 91 | 92 | 93 | *'maximizer_set_default_mapping'* 94 | Default: 1 95 | 96 | Whether Maximizer should set default mappings or not: > 97 | 98 | let g:maximizer_set_default_mapping = 1 99 | 100 | < 101 | 102 | *'maximizer_set_mapping_with_bang'* 103 | Default: 0 104 | 105 | Whether Maximizer should set default mappings with banged version or not: > 106 | 107 | let g:maximizer_set_mapping_with_bang = 0 108 | 109 | < 110 | 111 | *'maximizer_default_mapping_key'* 112 | Default: '' 113 | 114 | The default mappings key: > 115 | 116 | let g:maximizer_default_mapping_key = '' 117 | 118 | < 119 | 120 | *'maximizer_restore_on_winleave'* 121 | Default: 0 122 | 123 | Restore original windows sizes automatically when leaving maximized window: > 124 | 125 | let g:maximizer_restore_on_winleave = 1 126 | 127 | < 128 | 129 | ---------------------------------------------------------------------------- 130 | 4. Author and License *maximizer-author-license* 131 | 132 | Maximizer was written by Szymon Wrozynski and Contributors 133 | (https://github.com/szw/vim-maximizer/commits/master). It is licensed 134 | under the same terms as Vim itself. For more info see |license|. 135 | 136 | vim:tw=78:ts=8:ft=help:norl: 137 | -------------------------------------------------------------------------------- /plugin/maximizer.vim: -------------------------------------------------------------------------------- 1 | " vim-maximizer - Maximizes and restores the current window 2 | " Maintainer: Szymon Wrozynski 3 | " Version: 1.0.5 4 | " 5 | " Installation: 6 | " Place in ~/.vim/plugin/maximizer.vim or in case of Pathogen: 7 | " 8 | " cd ~/.vim/bundle 9 | " git clone https://github.com/szw/vim-maximizer.git 10 | " 11 | " License: 12 | " Copyright (c) 2012-2015 Szymon Wrozynski and Contributors. 13 | " Distributed under the same terms as Vim itself. 14 | " See :help license 15 | " 16 | " Usage: 17 | " See :help maximizer 18 | " https://github.com/szw/vim-maximizer/blob/master/README.md 19 | 20 | if exists('g:loaded_vim_maximizer') || &cp || v:version < 700 21 | finish 22 | endif 23 | 24 | let g:loaded_vim_maximizer = 1 25 | 26 | if !exists('g:maximizer_set_default_mapping') 27 | let g:maximizer_set_default_mapping = 1 28 | endif 29 | 30 | if !exists('g:maximizer_set_mapping_with_bang') 31 | let g:maximizer_set_mapping_with_bang = 0 32 | endif 33 | 34 | if !exists('g:maximizer_restore_on_winleave') 35 | let g:maximizer_restore_on_winleave = 0 36 | endif 37 | 38 | if !exists('g:maximizer_default_mapping_key') 39 | let g:maximizer_default_mapping_key = '' 40 | endif 41 | 42 | command! -bang -nargs=0 -range MaximizerToggle :call s:toggle(0) 43 | 44 | if g:maximizer_set_default_mapping 45 | let command = ':MaximizerToggle' 46 | 47 | if g:maximizer_set_mapping_with_bang 48 | let command .= '!' 49 | endif 50 | 51 | silent! exe 'nnoremap ' . g:maximizer_default_mapping_key . ' ' . command . '' 52 | silent! exe 'vnoremap ' . g:maximizer_default_mapping_key . ' ' . command . 'gv' 53 | silent! exe 'inoremap ' . g:maximizer_default_mapping_key . ' ' . command . '' 54 | endif 55 | 56 | fun! s:maximize() 57 | let t:maximizer_sizes = { 'before': winrestcmd() } 58 | vert resize | resize 59 | let t:maximizer_sizes.after = winrestcmd() 60 | normal! ze 61 | endfun 62 | 63 | fun! s:restore() 64 | if exists('t:maximizer_sizes') 65 | silent! exe t:maximizer_sizes.before 66 | if t:maximizer_sizes.before != winrestcmd() 67 | wincmd = 68 | endif 69 | unlet t:maximizer_sizes 70 | normal! ze 71 | end 72 | endfun 73 | 74 | fun! s:toggle(force) 75 | if exists('t:maximizer_sizes') && (a:force || (t:maximizer_sizes.after == winrestcmd())) 76 | call s:restore() 77 | elseif winnr('$') > 1 78 | call s:maximize() 79 | endif 80 | endfun 81 | 82 | if g:maximizer_restore_on_winleave 83 | augroup maximizer 84 | au! 85 | au WinLeave * call s:restore() 86 | augroup END 87 | endif 88 | --------------------------------------------------------------------------------