{"id":13503343,"url":"https://github.com/marklcrns/vim-smartq","last_synced_at":"2025-03-29T14:31:20.333Z","repository":{"id":53867694,"uuid":"376382425","full_name":"marklcrns/vim-smartq","owner":"marklcrns","description":"Master key for exiting or deleting nvim/vim buffers with respect to window splits and tabs.","archived":false,"fork":false,"pushed_at":"2022-09-06T00:50:30.000Z","size":37,"stargazers_count":45,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-31T23:31:05.265Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marklcrns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-12T20:56:11.000Z","updated_at":"2023-07-24T08:11:50.000Z","dependencies_parsed_at":"2022-08-24T11:31:25.823Z","dependency_job_id":null,"html_url":"https://github.com/marklcrns/vim-smartq","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marklcrns%2Fvim-smartq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marklcrns%2Fvim-smartq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marklcrns%2Fvim-smartq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marklcrns%2Fvim-smartq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marklcrns","download_url":"https://codeload.github.com/marklcrns/vim-smartq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246196973,"owners_count":20739205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:47.556Z","updated_at":"2025-03-29T14:31:20.059Z","avatar_url":"https://github.com/marklcrns.png","language":"Vim Script","funding_links":[],"categories":["Vim Script"],"sub_categories":[],"readme":"# vim-smartq\n\nMaster key for quitting vim buffers.\n\nExit/Delete buffer with respect to window splits and tabs, and other types of\nbuffer.\n\n## Features\n\nPreserve splits across tabs\n\n![Preserve Splits](https://i.imgur.com/uKRWrjS.gif)\n\n[Zen-mode](https://github.com/folke/zen-mode.nvim) Integration\n\n![Zen-mode Integration](https://i.imgur.com/XuZZjaG.gif)\n\n[Goyo](https://github.com/junegunn/goyo.vim) Integration\n\n![Goyo Integration](https://i.imgur.com/sB70XEK.gif)\n\nClose all diff buffers\n\n![Diff](https://i.imgur.com/qSTQfGl.gif)\n\nAdditional features\n\n- Close all splits in current tab when one empty modifiable buffer remaining\n  with multiple splits.\n- Auto wipe empty buffers when deleting/wiping a buffer\n\n## Installation\n\nUsing [vim-plug](https://github.com/junegunn/vim-plug)\n\n```vim\nPlug 'marklcrns/vim-smartq'\n```\n\nUsing [dein](https://github.com/Shougo/dein.vim)\n\n```vim\ncall dein#add('marklcrns/vim-smartq')\n```\n\nother package managers may be used as well.\n\n## Usage\n\nPlug and play. Automatically remap macro record `q` to `Q`, then map `q` to\n`\u003cPlug\u003e(smartq_this)` and `\u003cC-q\u003e` to `\u003cPlug\u003e(smartq_this_force)`\n\n```vim\n:SmartQ {buffer}      \" Smart quit (buffer name/number, optional)\n:SmartQ! {buffer}     \" Same as above but forced\n:SmartQSave {buffer}  \" Smart save before quit (buffer name/number, optional)\n:SmartQWipeEmpty      \" Wipe all empty (untitled) buffers\n:SmartQWipeEmpty!     \" Same as above but forced\n:SmartQCloseSplits    \" Close all splits excluding non-modifiable buffers\n```\n\n\u003e Tip: SmartQ(!) accepts both buffer name and buffer number (see :buffers). Also\n\u003e supports tab completion.\n\n## Mappings\n\n```vim\nnmap \u003cPlug\u003e(smartq_this)              \" :SmartQ\nnmap \u003cPlug\u003e(smartq_this_save)         \" :SmartQSave\nnmap \u003cPlug\u003e(smartq_this_force)        \" :SmartQ!\nnmap \u003cPlug\u003e(smartq_wipe_empty)        \" :SmartQWipeEmpty\nnmap \u003cPlug\u003e(smartq_wipe_empty_force)  \" :SmartQWipeEmpty!\nnmap \u003cPlug\u003e(smartq_close_splits)      \" :SmartQCloseSplits\n```\n\n## Customization\n\n```vim\n\" Default Settings\n\" -----\n\n\" Default mappings:\n\" Remaps normal mode macro record q to Q\n\" nnoremap Q q\n\" nmap q        \u003cPlug\u003e(smartq_this)\n\" nmap \u003cC-q\u003e    \u003cPlug\u003e(smartq_this_force)\nlet g:smartq_default_mappings = 1\n\n\" Excluded buffers to disable SmartQ and to preserve windows when closing splits\n\" on excluded buffers. Non-modifiable buffers are preserved by default.\nlet g:smartq_exclude_filetypes = [\n      \\ 'fugitive'\n      \\ ]\nlet g:smartq_exclude_buftypes= [\n      \\ ''\n      \\ ]\n\n\" Quit buffers using :q command. Non-modifiable and readonly file uses :q\nlet g:smartq_q_filetypes = [\n      \\ 'diff', 'git', 'gina-status', 'gina-commit', 'snippets',\n      \\ 'floaterm'\n      \\ ]\nlet g:smartq_q_buftypes = [\n      \\ 'quickfix', 'nofile'\n      \\ ]\n\n\" Wipe buffers using :bw command. Wiped buffers are removed from jumplist\n\" Default :bd\nlet g:smartq_bw_filetypes = [\n      \\ ''\n      \\ ]\nlet g:smartq_bw_buftypes = [\n      \\ ''\n      \\ ]\n\n\" Automatically wipe empty (with no changes) buffer(s)\nlet g:smartq_auto_wipe_emtpy = 1\n\" Best attemp to prevent exiting editor when left with an empty modifiable buffer\nlet g:smartq_no_exit = 0\n\" Automatically close splits when left with 1 modifiable buffer\nlet g:smartq_auto_close_splits = 0\n\n\" --- PLUGIN INTEGRATIONS\n\" When a plugin is disabled, use built-in fallbacks\n\n\" Enable Goyo\nlet g:smartq_goyo_integration = 1\n\" Enable Zen-mode\nlet g:smartq_zenmode_integration = 1\n```\n\n## SmartQ Quit Prioritization\n\nOrdered list of SmartQ quit conditions. Once `SmartQ` command is executed, it\nwill find and **ONLY EXECUTE ONE** condition from the list below.\n\n1. **Delete** (`bd`) all `diff` buffers. Check: `:set diff?`\n2. **Delete** (`bd`) [Zen-mode](https://github.com/folke/zen-mode.nvim) buffer\n2. **Delete** (`bd`) [Goyo](https://github.com/junegunn/goyo.vim) buffer\n3. **Quit** (`q`)\n  - `smartq_q_filetypes` or `smartq_q_buftypes`\n  - `terminal` buffer\n  - `nomodifiable` or `readonly` window\n  - Exceptions: `smartq_exclude_filetypes`, `smartq_exclude_buftypes`, empty `filetype` and `buftype`\n4. On final buffer\n  i. **Close** (`close!`) all `modifiable` windows OR **Quit all** (`qa`) if empty buffer\n5. On final buffer with `nomodifiable` window(s)\n  i. **Quit all** (`qa`) if empty buffer\n6. **Wipe** (`bw`)\n  - `smartq_bw_filetypes` or `smartq_bw_buftypes`\n  - Exceptions: `smartq_exclude_filetypes`, `smartq_exclude_buftypes`, empty `filetype` and `buftype`\n7. Catch all: **Delete** (`bd`) buffer. Check: `:buffers`\n\nSee `diff`, `modifiable`, `filetype`, `buftype`, `buffers`\n\n\n## Credits\n\n- [cespare/vim-sbd](https://github.com/cespare/vim-sbd)\n- [moll/vim-bbye](https://github.com/moll/vim-bbye)\n- [Asheq/close-buffers.vim](https://github.com/Asheq/close-buffers.vim)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarklcrns%2Fvim-smartq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarklcrns%2Fvim-smartq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarklcrns%2Fvim-smartq/lists"}