{"id":13898454,"url":"https://github.com/LucHermitte/lh-brackets","last_synced_at":"2025-07-17T15:33:37.650Z","repository":{"id":28648348,"uuid":"32167618","full_name":"LucHermitte/lh-brackets","owner":"LucHermitte","description":"LH's bracketing system for vim","archived":false,"fork":false,"pushed_at":"2024-06-23T14:48:26.000Z","size":779,"stargazers_count":52,"open_issues_count":5,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-23T15:59:47.371Z","etag":null,"topics":["brackets","vim","viml-library"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucHermitte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-13T16:37:56.000Z","updated_at":"2024-06-23T14:48:29.000Z","dependencies_parsed_at":"2024-02-08T16:51:19.850Z","dependency_job_id":null,"html_url":"https://github.com/LucHermitte/lh-brackets","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Flh-brackets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Flh-brackets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Flh-brackets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucHermitte%2Flh-brackets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucHermitte","download_url":"https://codeload.github.com/LucHermitte/lh-brackets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":214236347,"owners_count":15703475,"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":["brackets","vim","viml-library"],"created_at":"2024-08-06T18:04:18.170Z","updated_at":"2024-11-25T04:31:39.762Z","avatar_url":"https://github.com/LucHermitte.png","language":"Vim Script","readme":"# lh-brackets [![Last release][Releases-badge]][Releases-url] [![Build Status][gh-action-badge]][gh-action-result] [![Project Stats][openhub-badge]][openhub-url]\n\n[Releases-badge]:   https://img.shields.io/github/tag/LucHermitte/lh-brackets.svg\n[Releases-url]:     https://github.com/LucHermitte/lh-brackets/tags\n[gh-action-badge]:  ./../../actions/workflows/tests.yml/badge.svg?branch=master \"Test\"\n[gh-action-result]: ./../../actions/workflows/tests.yml?query=branch%3Amaster\n[openhub-badge]:    https://www.openhub.net/p/21020/widgets/project_thin_badge.gif\n[openhub-url]:      https://www.openhub.net/p/21020\n\n## Features\n\nlh-brackets (ex- map-tool) provides various commands and functions to help design smart and advanced mappings dedicated to text insertion.\n\nIt is made of three sub-systems:\n  * [the core bracketing-system](#the-bracketing-subsystem),\n  * [a placeholder subsystem](#the-placeholder-subsystem),\n  * [various Vim functions to support ftplugin definitions](#the-vim-library).\n\n### The bracketing subsystem\n\n#### Brackets insertion\n\nThis subsystem provides a command that helps define INSERT-, NORMAL-, and VISUAL-mode mappings to insert any pairs of brackets-like characters.\n\n  * The INSERT-mode mappings will\n    * insert the pair of brackets-like characters when the opening one is triggered, add a placeholder after the closing character, and move the cursor between the two bracket characters;\n    * insert the closing character when pressed, or move after it if it is the next character after the cursor ;\n    * delete the current pair of empty brackets when `\u003cBS\u003e` is hit from within the brackets (following placeholders will also be deleted) (this can be disabled by setting `[gb]:cb_delete_empty_brackets` to 0)\n    * insert an extra newline when `\u003cCR\u003e` is hit within an empty pair of curly-brackets {} (this can be disabled by setting `[gb]:cb_newline_within_empty_brackets` to 0)\n  * The VISUAL-mode mapping will surround the current selection with the pair of bracket-like characters ;\n  * The NORMAL-mode mapping will select the current word (or the current line depending on the use of the newline (`-nl`) option), and then surround this selection with the pair of bracket-like characters.\n\nIt is possible to:\n  * tune what is exactly inserted in INSERT-mode (thanks to the `-open` and `-close` options),\n  * not insert the placeholder (depending on `b:usemark` value),\n  * specify which keys sequence actually triggers the mappings defined (thanks to the `-trigger` option),\n  * define the mappings only in some modes (thanks to the options `-insert`, `-visual`, and also `-normal`)\n  * make the mappings line-wise (thanks to the `-nl` option),\n  * tune how the NORMAL-mode mapping select a current _anything_ (thanks to the `-normal` option),\n  * toggle the definitions of all the brackets mappings by pressing `\u003cF9\u003e` (`:h \u003cPlug\u003eToggleBrackets`) ;\n  * make the mappings global with `:Brackets!`, or local to a buffer with `:Brackets`. ;\n  * neutralize the INSERT-mode mappings:\n    * for specific filetypes with `-but` option\n    * when the cursor is not under a space, coma, (semi-)colon, a equal sign, a\n      closing pair character or at the end of line by default -- it will be\n      possible to tune this feature in a later version\n  * specify exactly which is the canonical pair for deletion when it's not immediate from the context (thanks to the `-pair` option)\n\n\nHere is an excerpt from the C\u0026C++ brackets definitions, see the documentation for more help.\n```\nlet b:usemarks         = 1\nlet b:cb_jump_on_close = 1\n\n:Brackets { } -visual=0 -nl\n:Brackets { } -visual=0 -trigger=#{\n:Brackets { } -visual=1 -insert=0 -nl -trigger=\u003clocalleader\u003e{\n:Brackets { } -visual=1 -insert=0\n\n:Brackets ( )\n:Brackets [ ] -visual=0\n:Brackets [ ] -insert=0 -trigger=\u003clocalleader\u003e[\n:Brackets \" \" -visual=0 -insert=1 -escapable\n:Brackets \" \" -visual=1 -insert=0 -trigger=\"\"\n:Brackets ' ' -visual=0 -insert=1\n:Brackets ' ' -visual=1 -insert=0 -trigger=''\n:Brackets \u003c \u003e -open=function('lh#cpp#brackets#lt') -visual=0\n```\n\n**Note:** This feature has been completely rewritten for the version 1.0.0 of map-tools. The old way of tuning the brackets insertion is no longer available.\n\nBy default, the [mappings are active for most filetypes](doc/default_brackets.md).\n\n#### Brackets replacement\n\nlh-brackets provides mappings (originally from auctex.vim) to replace a pair of bracket-characters by another pair of bracket-characters. See `:h brackets_manipulations` for more information.\n\n\n### The placeholder subsystem\n\nThis subsystem provides functions and mappings to:\n  * mark places in the code where we could jump to later,  \n    See the help about `!mark!`, `lh#marker#txt()`, and `\u003cPlug\u003eMarkersMark`\n  * jump forward and backward to those places.  \n    See the help about `!jump!`, and `\u003cPlug\u003eMarkersJumpF`\n  * close all placeholders on the same line that are after closing bracket-like\n    characters and jump to the last one -- see\n    `\u003cPlug\u003eMarkersCloseAllAndJumpToLast` which is binded by default to `\u003cM-End\u003e` (or `\u003cC-L\u003e$` in terminal instancef of Vim).\n\nThe marker/placeholder characters:\n  * default to the French quote characters («»),\n  * can be specified on a filetype basis,\n  * are converted to match the current encoding,\n  * can be shared with the ones from imaps.vim (`:h g:use_place_holders`).\n\nJumping to the next/previous placeholder:\n  * is binded to `\u003cM-Del\u003e` (GUI) or `\u003cC-J\u003e` (terminal) by default (see `:h \u003cPlug\u003eMarkersJumpF`), or `\u003cM-S-Del\u003e`/`\u003cC-L\u003e\u003cS-Del\u003e` to jump backward. Can be disabled by setting `g:marker_define_jump_mappings` to 0.\n  * can be tuned to delete or select the placeholder the cursor is jumping to (`:h g:marker_prefers_select`, `:h g:marker_select_empty_marks`),\n  * can select or ignore the placeholder where the cursor is currently within (if any) (`:h g:marker_select_current`, `:h g:marker_select_current_fwd`),\n  * may move the line of the placeholder (we jump to) to the middle of the window (`:h g:marker_center`),\n  * respects `'wrapscan'`,\n  * opens the folder where the placeholder, we jump to, is,\n  * doesn't break _redo_ (is the case of empty placeholders, when placeholders\n    are deleted instead of selected) ; this feature requires Vim 7.4-849.\n\n\n### The Vim library\n\nAs [lh-vim-lib](http://github.com/LucHermitte/lh-vim-lib), map-tools provides a few functions of its own. All these functions are specialized into the definition of smart abbreviations and INSERT-mode mappings.\n\n| Function                                      | Purpose                                                                                                                    |\n|:----------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------|\n| `lh#map#no_context()`, `lh#map#no_context2()` | Core functions to define mappings that only expand outside of _string_, _comment_, and _character_ contexts                |\n| `lh#map#4_these_contexts()`                   | Like `lh#map#no_context()`, except this time we can specify which text must be returned depending on the current context   |\n| `lh#map#insert_around_visual()`               | This is the core surrounding function ; the surrounding text is not interpreted                                            |\n| `lh#map#surround()`                           | Interprets the `!.*!` mappings that are passed to `lh#map#insert_around_visual()` (`!cursorhere!` tells were to put the cursor). This function also recognises when the selected area is actually a marker/placeholder in order to not surround, but expand instead. |\n| `lh#map#build_map_seq()`                      | Core function that interprets `!.*!` mappings                                                                              |\n| `lh#map#eat_char()`, `:I(nore)abbr`           | Permits to define abbreviations that do not insert a whitespace when the `\u003cspace\u003e` key is used to trigger the abbreviation |\n| `lh#map#insert_seq()`                         | High level function that interprets `!.*!` mappings, and take the context into account                                     |\n\n# Installation\n  * Requirements: Vim 7.+ (7.4-849 in order to support redo), [lh-vim-lib](http://github.com/LucHermitte/lh-vim-lib) v5.3.0+, [lh-style](http://github.com/LucHermitte/lh-style) v1.0.0+ for unit testing.\n  * With [vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager), install lh-brackets (this is the preferred method because of the dependencies)\n\n    ```vim\n    ActivateAddons lh-brackets\n    ```\n\n  * or with [vim-flavor](https://github.com/kana/vim-flavor) (which also support dependencies)\n\n    ```\n    flavor 'LucHermitte/lh-brackets'\n    ```\n\n  * or you can clone the git repositories\n\n    ```bash\n    git clone git@github.com:LucHermitte/lh-vim-lib.git\n    git clone git@github.com:LucHermitte/lh-brackets.git\n    ```\n\n  * or with Vundle/NeoBundle:\n\n    ```vim\n    Bundle 'LucHermitte/lh-vim-lib'\n    Bundle 'LucHermitte/lh-brackets'\n    ```\n\n## Credits\n  * This bracketing system is actually a variation on [Stephen Riehm's original bracketing system](http://mywebpage.netscape.com/bbenjif/vim/Riehm/doc/) ;\n  * The brackets manipulation comes from Saul Lubkin code, also present in [auctex.vim](http://www.vim.org/scripts/script.php?script_id=162) ;\n  * Using SELECT-mode when reaching a placeholder was a suggestion from Gergely Kontra.\n\n## See also\n  * [imaps.vim, from LaTeX-suite](http://www.vim.org/scripts/script.php?script_id=475), with which map-tools is compatible (there is no conflictual mappings if both are installed) ;\n  * All the [brackets related tips on vim.wikia](http://vim.wikia.com/wiki/Category:Brackets) ;\n  * Most of my ftplugins for examples of use, or more simply the [Python ftplugin](ftplugin/python/python_snippets.vim) shipped with lh-brackets.\n  * [muTemplate](http://github.com/LucHermitte/mu-template), a template-files expander built on top of map-tools.\n  * [surround plugin on SF](http://www.vim.org/scripts/script.php?script_id=1697)\n","funding_links":[],"categories":["Vim Script"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucHermitte%2Flh-brackets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLucHermitte%2Flh-brackets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucHermitte%2Flh-brackets/lists"}