├── doc ├── tags └── vim-tmuxlike.txt ├── LICENSE ├── README.md ├── plugin └── vim-tmuxlike.vim └── autoload └── tmuxlike.vim /doc/tags: -------------------------------------------------------------------------------- 1 | vim-tmuxlike.txt vim-tmuxlike.txt /*vim-tmuxlike.txt* 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-tmuxlike 2 | 3 | Add tmux operating habits to vim. 4 | 5 | If you are quite addicted to tmux, you might need this plugin to make your vim work a bit like tmux. 6 | 7 | ## TOC 8 | 9 | 10 | 11 | * [Intro](#intro) 12 | * [Installation](#installation) 13 | * [Configuration](#configuration) 14 | * [Others](#others) 15 | 16 | 17 | 18 | ## Intro 19 | 20 | **Prefix key** 21 | 22 | Just like ``(usually `CTRL-B`) in tmux, there's a prefix key in vim-tmuxlike.
23 | I use ``(`CTRL-A`) as the default prefix key. You need to change it if you have the same keymap in tmux. 24 | 25 | **Features** 26 | 27 | Tmux users may be familiar with these basic operation. 28 | 29 | Every keymap should start with ``. 30 | 31 | - `h` `j` `k` `l` `Left` `Down` `Up` `Right` change buffer 32 | - `H` `J` `K` `L` enter resize-mode and smoothly resize current window with direction key (vim only; nvim version still WIP) 33 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/resize_mode.gif) 34 | - `?` open vim-tmuxlike's helppage 35 | - `z` toggle buffer zoom mode 36 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/toggle_zoom.gif) 37 | - `%` split window; open new buffer oh the right side 38 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/vsplit_new.gif) 39 | - `|` split current buffer oh the right side (custom: `g:tmuxlike_key_vsplit`) 40 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/vsplit_cur.gif) 41 | - `"` vertically split window; open new buffer downside 42 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/split_new.gif) 43 | - `_` split current buffer downside (custom: `g:tmuxlike_key_hsplit`) 44 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/split_cur.gif) 45 | - `c` open a new tab with an empty window after the last tab 46 | - `` `` select previous tab 47 | `n` `` `` select next tab 48 | - `x` forcely close current buffer 49 | - `&` forcely close current tab 50 | - `~` show history messages 51 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/hist_msg.gif) 52 | - `!` break current buffer (move current buffer to new tabpage) 53 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/break_cur.gif) 54 | - `d` detach/suspend vim (the same as CTRL-Z) 55 | - `r` redraw current buffer 56 | - `]` paste [from register *] 57 | - `;` choose last buffer 58 | 59 | These keymaps need [t9md/vim-choosewin](https://github.com/t9md/vim-choosewin) installed. 60 | - `q` `s` `=` enter choosewin mode 61 | ![choose_win](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/choose_win.gif) 62 | 63 | ## Installation 64 | 65 | - use [vim-plug](https://github.com/junegunn/vim-plug): 66 | ``` 67 | Plug 'karmenzind/vim-tmuxlike' 68 | ``` 69 | 70 | ## Configuration 71 | 72 | **prefix key** 73 | 74 | Feel free to change the prefix key. 75 | I recommend using a 'CTRL-' key combination which will be really convenient (e.g. with default prefix ``, you just need to hold CTRL and type 'ah' for ``). 76 | 77 | ```vim 78 | " use CTRL-A (default) 79 | nmap (tmuxlike-prefix) 80 | " use CTRL-\ 81 | nmap (tmuxlike-prefix) 82 | " use double leader (it will be `\\` if you haven't change the mapleader) 83 | nmap (tmuxlike-prefix) 84 | ``` 85 | 86 | **operation keymaps** 87 | 88 | ```vim 89 | " use + to split current buffer 90 | let g:tmuxlike_key_vsplit = '\' " default value: \| (slash is for escaping) 91 | let g:tmuxlike_key_hsplit = '-' " default value: _ 92 | ``` 93 | 94 | **others** 95 | 96 | ```vim 97 | " View :messages in a scratch buffer or a floating window. Options: float, scratch(default) 98 | let g:tmuxlike_messages_container = 'scratch' 99 | ``` 100 | 101 | ## Others 102 | 103 | TODO: 104 | 105 | - (WIP) list and search tab/win with fzf/floating 106 | - all keymaps configurable 107 | 108 | If you have any problem or advice, please [create an issue](https://github.com/Karmenzind/vim-tmuxlike/issues/new) and I'll fix it ASAP. 109 | -------------------------------------------------------------------------------- /doc/vim-tmuxlike.txt: -------------------------------------------------------------------------------- 1 | *vim-tmuxlike.txt* Add tmux operating habits to vim. 2 | 3 | |tmuxlike-intro| vim-tmuxlike 4 | |tmuxlike-TOC| TOC 5 | |tmuxlike-Intro| Intro 6 | |tmuxlike-Installation| Installation 7 | |tmuxlike-Configuration| Configuration 8 | |tmuxlike-Others| Others 9 | 10 | VIM-TMUXLIKE *tmuxlike-intro* 11 | 12 | Add tmux operating habits to vim. 13 | 14 | If you are quite addicted to tmux, you might need this plugin to make your vim work a bit like tmux. 15 | 16 | 17 | TOC *tmuxlike-TOC* 18 | 19 | [Intro](#intro) 20 | 21 | [Installation](#installation) 22 | 23 | [Configuration](#configuration) 24 | 25 | [Others](#others) 26 | 27 | 28 | INTRO *tmuxlike-Intro* 29 | 30 | **Prefix key** 31 | 32 | Just like ``(usually `CTRL-B`) in tmux, there's a prefix key in vim-tmuxlike.
33 | I use ``(`CTRL-A`) as the default prefix key. You need to change it if you have the same keymap in tmux. 34 | 35 | **Features** 36 | 37 | Tmux users may be familiar with these basic operation. 38 | 39 | Every keymap should start with ``. 40 | 41 | `?` open vim-tmuxlike's helppage 42 | 43 | `z` toggle buffer zoom mode 44 | 45 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/toggle_zoom.gif) 46 | 47 | `%` split window; open new buffer oh the right side 48 | 49 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/vsplit_new.gif) 50 | 51 | `|` split current buffer oh the right side (custom: `g:tmuxlike_key_vsplit`) 52 | 53 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/vsplit_cur.gif) 54 | 55 | `"` vertically split window; open new buffer downside 56 | 57 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/split_new.gif) 58 | 59 | `_` split current buffer downside (custom: `g:tmuxlike_key_hsplit`) 60 | 61 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/split_cur.gif) 62 | 63 | `c` open a new tab with an empty window after the last tab 64 | 65 | `` `` select previous tab 66 | 67 | `n` `` `` select next tab 68 | 69 | `x` forcely close current buffer 70 | 71 | `&` forcely close current tab 72 | 73 | `~` show history messages 74 | 75 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/hist_msg.gif) 76 | 77 | `!` break current buffer (move current buffer to new tabpage) 78 | 79 | ![](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/break_cur.gif) 80 | 81 | `d` detach/suspend vim (the same as CTRL-Z) 82 | 83 | `r` redraw current buffer 84 | 85 | `]` paste [from register *] 86 | 87 | `;` choose last buffer 88 | 89 | `h` `j` `k` `l` `Left` `Down` `Up` `Right` change buffer 90 | 91 | `H` `J` `K` `L` resize current window 92 | 93 | These keymaps need [t9md/vim-choosewin](https://github.com/t9md/vim-choosewin) installed. 94 | 95 | `q` `s` `=` enter choosewin mode 96 | 97 | ![choose_win](https://raw.githubusercontent.com/Karmenzind/i/master/vim-tmuxlike/choose_win.gif) 98 | 99 | 100 | INSTALLATION *tmuxlike-Installation* 101 | 102 | use [vim-plug](https://github.com/junegunn/vim-plug): 103 | 104 | > 105 | Plug 'karmenzind/vim-tmuxlike' 106 | < 107 | 108 | use [Vundle](https://github.com/VundleVim/Vundle.vim): 109 | 110 | > 111 | Plugin 'karmenzind/vim-tmuxlike' 112 | < 113 | 114 | 115 | CONFIGURATION *tmuxlike-Configuration* 116 | 117 | **prefix key** 118 | 119 | Feel free to change the prefix key. 120 | I recommend using a 'CTRL-' key combination which will be really convenient (e.g. with default prefix ``, you just need to hold CTRL and type 'ah' for ``). 121 | 122 | > 123 | " use CTRL-A (default) 124 | nmap (tmuxlike-prefix) 125 | " use CTRL-\ 126 | nmap (tmuxlike-prefix) 127 | " use double leader (it will be `\\` if you haven't change the mapleader) 128 | nmap (tmuxlike-prefix) 129 | < 130 | 131 | **operation keymaps** 132 | 133 | > 134 | " use + to split current buffer 135 | let g:tmuxlike_key_vsplit = '\' " default value: \| (slash is for escaping) 136 | let g:tmuxlike_key_hsplit = '-' " default value: _ 137 | < 138 | 139 | **others** 140 | 141 | > 142 | " View :messages in a scratch buffer or a floating window. Options: float, scratch(default) 143 | let g:tmuxlike_messages_container = 'scratch' 144 | < 145 | 146 | 147 | OTHERS *tmuxlike-Others* 148 | 149 | TODO: 150 | 151 | (WIP) list and search tab/win with fzf/floating 152 | 153 | all keymaps configurable 154 | 155 | If you have any problem or advice, please [create an issue](https://github.com/Karmenzind/vim-tmuxlike/issues/new) and I'll fix it ASAP. 156 | 157 | 158 | 159 | vim:tw=78:ts=8:ft=help:norl: 160 | -------------------------------------------------------------------------------- /plugin/vim-tmuxlike.vim: -------------------------------------------------------------------------------- 1 | " Name: vim-tmuxlike 2 | " Version: 0.1000000001 3 | " Author: github.com/Karmenzind 4 | 5 | " TODO: 6 | " make `resize` and `change tab` repeatable 7 | " more interative 8 | 9 | if exists("g:loaded_vim_tmuxlike") 10 | finish 11 | endif 12 | let g:loaded_vim_tmuxlike = 1 13 | 14 | " -------------------------------------------- 15 | " variables 16 | " -------------------------------------------- 17 | 18 | let g:tmuxlike_key_vsplit = get(g:, 'tmuxlike_key_vsplit', '\|') 19 | let g:tmuxlike_key_hsplit = get(g:, 'tmuxlike_key_hsplit', '_') 20 | 21 | " -------------------------------------------- 22 | " funcs 23 | " -------------------------------------------- 24 | 25 | 26 | " /* keymap */ 27 | function! s:TmuxLikeMap(mapfunc, key, value) 28 | let l:_f = a:mapfunc 29 | let l:_k = a:key 30 | let l:_v = a:value 31 | execute l:_f . ' (tmuxlike-prefix)' . l:_k . ' ' . l:_v 32 | endfunction 33 | 34 | " -------------------------------------------- 35 | " others 36 | " -------------------------------------------- 37 | 38 | function! s:ShowMessages() 39 | execute 'messages' 40 | " TODO (k): <2022-10-10> 41 | endfunction 42 | 43 | " -------------------------------------------- 44 | " buffers 45 | " -------------------------------------------- 46 | 47 | function! s:ChooseBuffer() 48 | " TODO (k): <2022-10-10> 49 | endfunction 50 | 51 | " -------------------------------------------- 52 | " tabs 53 | " -------------------------------------------- 54 | 55 | function! s:CloseCurrentTab() 56 | if tabpagenr('$') == 1 57 | let prompt = "Kill the last tab?" 58 | else 59 | let prompt = printf("Kill tab %d?", tabpagenr()) 60 | endif 61 | 62 | let choice = confirm(prompt, "&Yes\n&No", 2, "Warning") 63 | if choice == 1 64 | if tabpagenr('$') == 1 65 | exec 'qa!' 66 | else 67 | exec 'tabclose' 68 | endif 69 | endif 70 | endfunction 71 | 72 | function! s:CloseCurrentWin() 73 | let choice = confirm(printf("Kill window %d?", winnr()), "&Yes\n&No", 2, "Warning") 74 | if choice == 1 75 | exec 'q' 76 | endif 77 | endfunction 78 | 79 | " -------------------------------------------- 80 | " maps 81 | " -------------------------------------------- 82 | 83 | " /* tmux origin */ 84 | " help 85 | call s:TmuxLikeMap('nnoremap', '?', ':help tmuxlike') 86 | " toggle zoom 87 | call s:TmuxLikeMap('nnoremap', 'z', ':call tmuxlike#ZoomToggle()') 88 | " h split 89 | call s:TmuxLikeMap('nnoremap', '"', ':new') 90 | " call s:TmuxLikeMap('nnoremap', '_', ':split') 91 | call s:TmuxLikeMap('nnoremap', g:tmuxlike_key_hsplit, ':split') 92 | " v split 93 | call s:TmuxLikeMap('nnoremap', '%', ':vnew') 94 | " call s:TmuxLikeMap('nnoremap', '\|', ':vsplit') 95 | call s:TmuxLikeMap('nnoremap', g:tmuxlike_key_vsplit, ':vsplit') 96 | " new tab 97 | call s:TmuxLikeMap('nnoremap', 'c', ':$tabnew') 98 | " change tab 99 | call s:TmuxLikeMap('nnoremap', '', ':tabprevious') 100 | call s:TmuxLikeMap('nnoremap', '', ':tabprevious') 101 | call s:TmuxLikeMap('nnoremap', '', ':tabnext') 102 | call s:TmuxLikeMap('nnoremap', '', ':tabnext') 103 | call s:TmuxLikeMap('nnoremap', '', ':tabnext') 104 | " confirm quit current buffer 105 | call s:TmuxLikeMap('nnoremap', 'x', ':call tmuxlike#CloseCurrentWin()') 106 | " confirm close current tab 107 | call s:TmuxLikeMap('nnoremap', '&', ':call tmuxlike#CloseCurrentTab()') 108 | " show history 109 | call s:TmuxLikeMap('nnoremap', '~', ':call tmuxlike#ShowMessages()') 110 | " break pane TODO: how to move the unsaved buffer? 111 | call s:TmuxLikeMap('nnoremap', '!', ':call tmuxlike#TabSplitAndCloseCurrentBuf()') 112 | " detach 113 | call s:TmuxLikeMap('nnoremap', 'd', ':suspend') 114 | " refresh 115 | call s:TmuxLikeMap('nnoremap', 'r', ':redraw') 116 | " time 117 | call s:TmuxLikeMap('nnoremap', 't', ':echom strftime("%c")') 118 | " buffers 119 | " call s:TmuxLikeMap('nnoremap', 'w', ':call ShowBuffers()') 120 | 121 | " TODO: 122 | " toggle layout 123 | " call s:TmuxLikeMap('nnoremap', '', 'r') 124 | " rotate window 125 | " call s:TmuxLikeMap('nnoremap', '', '"+p') 126 | 127 | " /* unnecessary tmux origin */ 128 | " paste (from system clipboard) 129 | call s:TmuxLikeMap('nnoremap', ']', '"+p') 130 | " last buffer 131 | call s:TmuxLikeMap('nnoremap', ';', 'p') 132 | " select buffer 133 | call s:TmuxLikeMap('nnoremap', 'h', 'h') 134 | call s:TmuxLikeMap('nnoremap', 'j', 'j') 135 | call s:TmuxLikeMap('nnoremap', 'k', 'k') 136 | call s:TmuxLikeMap('nnoremap', 'l', 'l') 137 | call s:TmuxLikeMap('nnoremap', '', 'h') 138 | call s:TmuxLikeMap('nnoremap', '', 'j') 139 | call s:TmuxLikeMap('nnoremap', '', 'k') 140 | call s:TmuxLikeMap('nnoremap', '', 'l') 141 | 142 | " resize 143 | if has('nvim') 144 | call s:TmuxLikeMap('nnoremap', 'H', '5<') 145 | call s:TmuxLikeMap('nnoremap', 'J', '5+') 146 | call s:TmuxLikeMap('nnoremap', 'K', '5-') 147 | call s:TmuxLikeMap('nnoremap', 'L', '5>') 148 | else 149 | call s:TmuxLikeMap('nnoremap', 'H', 'call tmuxlike#EnterResizeMode("H")') 150 | call s:TmuxLikeMap('nnoremap', 'J', 'call tmuxlike#EnterResizeMode("J")') 151 | call s:TmuxLikeMap('nnoremap', 'K', 'call tmuxlike#EnterResizeMode("K")') 152 | call s:TmuxLikeMap('nnoremap', 'L', 'call tmuxlike#EnterResizeMode("L")') 153 | endif 154 | 155 | " /* choose-win */ 156 | call s:TmuxLikeMap('nmap', 'q', '(choosewin)') 157 | call s:TmuxLikeMap('nmap', 's', '(choosewin)') 158 | call s:TmuxLikeMap('nmap', '=', '(choosewin)') 159 | 160 | " -------------------------------------------- 161 | " Initial 162 | " -------------------------------------------- 163 | 164 | nnoremap = :call tmuxlike#MakeWinEqual() 165 | 166 | if !hasmapto('(tmuxlike-prefix)') 167 | nmap (tmuxlike-prefix) 168 | endif 169 | 170 | -------------------------------------------------------------------------------- /autoload/tmuxlike.vim: -------------------------------------------------------------------------------- 1 | 2 | let s:messages_container = get(g:, 'tmuxlike_messages_container', 'scratch') 3 | 4 | 5 | function! s:TabSplitAndCloseCurrentBuf() 6 | let l:curbuf = expand('%') 7 | confirm quit 8 | exec 'tabe ' . l:curbuf 9 | endfunction 10 | 11 | " /* zoom utils */ 12 | function! s:ResetTabZoomStatus() 13 | let t:tmuxlike_zoomed_win = v:null 14 | endfunction 15 | 16 | function! s:ZoomInCurrent() 17 | let l:ignored_fts = ['nerdtree', 'qf', 'tagbar'] 18 | if index(l:ignored_fts, tolower(&ft)) >= 0 19 | echom 'Ignored filetype: ' . &ft | return 20 | endif 21 | for _c in ['NERDTreeClose', 'TagbarClose', 'cclose'] 22 | silent! execute _c 23 | endfor 24 | silent! execute 'resize | vertical resize' 25 | let t:tmuxlike_zoomed_win = win_getid() 26 | endfunction 27 | 28 | function! tmuxlike#MakeWinEqual() 29 | execute "normal! \=" 30 | call s:ResetTabZoomStatus() 31 | endfunction 32 | 33 | " -------------------------------------------- 34 | " resize mode 35 | " -------------------------------------------- 36 | 37 | let s:resizing_win = v:null 38 | 39 | function! s:DoResize(key) 40 | if a:key == 'L' 41 | call execute('vertical' .. s:resizing_win .. "resize +3") 42 | elseif a:key == 'H' 43 | call execute('vertical' .. s:resizing_win.."resize -3") 44 | elseif a:key == 'J' 45 | call execute(s:resizing_win .. 'resize +3') 46 | elseif a:key == 'K' 47 | call execute(s:resizing_win .. 'resize -3') 48 | endif 49 | endfunction 50 | 51 | function! tmuxlike#ResizeModeFilter(winid, key) abort 52 | " echom "resizing win ".. s:resizing_win 53 | if a:key == 'q' || a:key == "\" || a:key == "\" 54 | call popup_close(a:winid) 55 | else 56 | call s:DoResize(a:key) 57 | endif 58 | return 1 59 | endfunction 60 | 61 | let s:saved_map = v:null 62 | 63 | function! tmuxlike#AfterResizing(...) 64 | if s:saved_map != v:null 65 | call mapset('n', 0, s:saved_map) 66 | endif 67 | endfunction 68 | 69 | function! tmuxlike#EnterResizeMode(key) abort 70 | let s:saved_map = maparg('K', 'n', 0, 1) 71 | silent nunmap K 72 | 73 | let s:resizing_win = winnr() 74 | let text = ["Resizing...", "Press H/J/K/L to resize, ESC/ENTER/q to quit"] 75 | 76 | let popup_win = popup_create(text, #{ 77 | \ line: 3, 78 | \ col: &columns - 1, 79 | \ pos: 'topright', 80 | \ zindex: 300, 81 | \ close: 'none', 82 | \ cursorline: v:true, 83 | \ border:[1,1,1,1], 84 | \ borderchars: ['─', '│', '─', '│', '╭', '╮', '╯', '╰'], 85 | \ highlight: 'Normal', 86 | \ borderhighlight: ['MoreMsg'], 87 | \ filtermode: 'a', 88 | \ filter: 'tmuxlike#ResizeModeFilter', 89 | \ callback: 'tmuxlike#AfterResizing', 90 | \}) 91 | call s:DoResize(a:key) 92 | endfunction 93 | 94 | " -------------------------------------------- 95 | " others 96 | " -------------------------------------------- 97 | 98 | function! tmuxlike#ShowMessages() abort 99 | let history = execute("messages") 100 | if len(history) == 0 101 | echo "No history message." 102 | return 103 | endif 104 | 105 | if s:messages_container == "scratch" 106 | execute "new [Messages]" 107 | " let win = winnr() 108 | let buf = bufnr() 109 | 110 | call append(0, history) 111 | execute '%s/\v[\x0]/\r/g' 112 | 113 | call setbufvar(buf, "&buftype", "nofile") 114 | call setbufvar(buf, "&bufhidden", "hide") 115 | call setbufvar(buf, "&swapfile", "0") 116 | call setbufvar(buf, "&wrap", "1") 117 | call setbufvar(buf, "&ft", "messages") 118 | elseif s:messages_container == "float" 119 | if has("nvim") 120 | execute 'messages' 121 | endif 122 | if has("popupwin") 123 | let history = execute("messages") 124 | let lines = split(history, '[\x0]', 0) 125 | 126 | let msg_win = popup_create(lines, #{ 127 | \ title: "Messages", 128 | \ line: 1, 129 | \ col: 10, 130 | \ minwidth: 20, 131 | \ time: 30000, 132 | \ tabpage: -1, 133 | \ zindex: 300, 134 | \ drag: 1, 135 | \ dragall: 1, 136 | \ highlight: 'WarningMsg', 137 | \ border: [1,1,1,1], 138 | \ padding: [0, 1, 0, 1], 139 | \ scrollbar: 1, 140 | \ pos: 'center', 141 | \ cursorline: 1, 142 | \ borderchars: ['-', '|', '-', '|', '┌', '┐', '┘', '└'], 143 | \ close: 'button', 144 | \ resize: 1, 145 | \ }) 146 | endif 147 | else 148 | execute 'messages' 149 | endif 150 | endfunction 151 | 152 | " -------------------------------------------- 153 | " buffers 154 | " -------------------------------------------- 155 | 156 | function! s:ChooseBuffer() 157 | endfunction 158 | 159 | " -------------------------------------------- 160 | " tabs 161 | " -------------------------------------------- 162 | 163 | function! tmuxlike#CloseCurrentTab() 164 | if tabpagenr('$') == 1 165 | let prompt = "Kill the last tab?" 166 | else 167 | let prompt = printf("Kill tab %d?", tabpagenr()) 168 | endif 169 | 170 | let choice = confirm(prompt, "&Yes\n&No", 2, "Warning") 171 | if choice == 1 172 | if tabpagenr('$') == 1 173 | exec 'qa!' 174 | else 175 | exec 'tabclose' 176 | endif 177 | endif 178 | endfunction 179 | 180 | function! tmuxlike#CloseCurrentWin() 181 | let choice = confirm(printf("Kill window %d?", winnr()), "&Yes\n&No", 2, "Warning") 182 | if choice == 1 183 | exec 'q' 184 | endif 185 | endfunction 186 | 187 | 188 | " -------------------------------------------- 189 | " exposed 190 | " -------------------------------------------- 191 | 192 | 193 | function! tmuxlike#ZoomToggle() 194 | if tabpagewinnr(tabpagenr(), '$') == 1 195 | call s:ResetTabZoomStatus() | return 196 | endif 197 | if !exists('t:tmuxlike_zoomed_win') 198 | call s:ResetTabZoomStatus() 199 | endif 200 | if t:tmuxlike_zoomed_win ==# win_getid() 201 | call s:MakeWinEqual() 202 | else 203 | call s:ZoomInCurrent() 204 | endif 205 | endfunction 206 | 207 | --------------------------------------------------------------------------------