{"id":13898538,"url":"https://github.com/tmsvg/pear-tree","last_synced_at":"2025-07-17T15:33:56.502Z","repository":{"id":42618244,"uuid":"123623095","full_name":"tmsvg/pear-tree","owner":"tmsvg","description":"A Vim auto-pair plugin that supports multi-character pairs, intelligent matching, and more","archived":false,"fork":false,"pushed_at":"2024-11-02T19:50:35.000Z","size":199,"stargazers_count":392,"open_issues_count":23,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-02T20:26:38.283Z","etag":null,"topics":["vim","vim-plugin","vim-plugins","viml"],"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/tmsvg.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":"2018-03-02T19:43:17.000Z","updated_at":"2024-11-02T19:50:39.000Z","dependencies_parsed_at":"2022-09-07T14:51:10.027Z","dependency_job_id":null,"html_url":"https://github.com/tmsvg/pear-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsvg%2Fpear-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsvg%2Fpear-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsvg%2Fpear-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmsvg%2Fpear-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmsvg","download_url":"https://codeload.github.com/tmsvg/pear-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226274926,"owners_count":17598861,"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":["vim","vim-plugin","vim-plugins","viml"],"created_at":"2024-08-06T18:04:20.490Z","updated_at":"2024-11-25T04:31:46.393Z","avatar_url":"https://github.com/tmsvg.png","language":"Vim Script","readme":"Pear Tree\n=========\nA painless, powerful Vim auto-pair plugin.\n\nPurpose\n-------\n**Pear Tree** automatically pairs parentheses, quotes, HTML tags, and many\nother text items based on a simple-to-define set of rules. It also provides\npair-wise deletion, newline expansion, and other typical auto-pair features\nwithout interfering with Vim's undo or dot-repeat functionality.\n\nInstallation\n------------\nFollow the instructions provided by your plugin manager. Using\n[vim-plug](https://github.com/junegunn/vim-plug), you would place the\nfollowing in your vimrc and run `:PlugInstall`\n\n```vim\nPlug 'tmsvg/pear-tree'\n```\n\nYou can also install Pear Tree manually by placing the files in their\nappropriate locations in your Vim directory. Remember to run `:helptags` if\nyou choose this method.\n\nFeatures\n--------\n### Multi-Character Pair Support\n\nPear Tree is not limited to pairing single characters like `(` with `)`, `{`\nwith `}`, and so on. If you would like to pair, say, `/*` with `*/` or `\u003c!--`\nwith `--\u003e`, simply add them to your `g:pear_tree_pairs` and it will work just\nas well.\n\n### Wildcard Support\n\nA powerful feature of Pear Tree is its support for wildcard string matching.\nThis is particularly useful for HTML tags, wherein there can be strings of\nsome arbitrary length between the `\u003c` and `\u003e` characters (e.g. `\u003cbody\u003e`,\n`\u003cul\u003e`, `\u003cp class=\"Foo\"\u003e`).\n\n### Dot-Repeatability\n\nPear Tree allows brace expansion without breaking Vim's dot-repeat *or* undo\nfunctionality. Consider this example:\n\n```c\n1  int foo();|\n2\n3  int bar();\n```\n\nType `\u003cBS\u003e {`\n\n```c\n1  int foo() {|}\n2\n3  int bar();\n```\n\nType `\u003cCR\u003e`:\n\n```c\n1  int foo() {\n2      |\n3\n4\n5  int bar();\n```\n\nNote that the closing pair disappears after pressing `\u003cCR\u003e`. This is required\nto not break dot-repeat, but it will be automatically restored later.\n\nNext, type `return 1;` and leave insert mode:\n\n```c\n1  int foo() {\n2      return 1;\n3  }\n4\n5  int bar();\n```\n\nFinally, move to line 5 and use the `.` command:\n\n```c\n1  int foo() {\n2      return 1;\n3  }\n4\n5  int bar() {\n6      return 1;\n7  }|\n```\n\nMany implementations of this feature cause the `.` command to only repeat\n`return 1;` instead of the entire typing sequence.\n\nHowever, if you would prefer expansion to behave like other plugins and text\neditors, you can prevent Pear Tree from erasing the closing string by setting\n`g:pear_tree_repeatable_expand` to `0`.\n\n### Smart Pairing\n\nPear Tree includes options to intelligently decide when an opening string\nshould be closed, when typing a closing character should move the cursor past\nan existing closer, and when both characters in a pair should be deleted when\npressing backspace. If these options are enabled, Pear Tree will examine the\nbalance of existing pairs to decide what action should be taken. It will choose\nthe action that makes nearby pairs properly balanced, as summarized in the\nfollowing table:\n\n|           | Before        | After (smart pairing) | After (no smart pairing)\n| --------- | ------------- | --------------------- | ------------------------ |\n| Opener    | `foo(bar\\|))` | `foo(bar(\\|))`        | `foo(bar(\\|)))`          |\n| Closer    | `foo(bar(\\|)` | `foo(bar()\\|)`        | `foo(bar()\\|`            |\n| Backspace | `foo((\\|)`    | `foo(\\|)`             | `foo(\\|`                 |\n\nSmart pairs must be [enabled manually](#defaults).\n\nUsage\n-----\nPear Tree's primary features are enabled automatically, but some useful options\nand mappings must be set manually. Please read `:help pear-tree` for useful\ninformation on how to define your own pairs, use wildcards, customize mappings,\nand more.\n\n### Defaults\n\n**Note:** The following code is only here to summarize the available options\nand show what Pear Tree sets them to by default. You only need to copy it to\nyour config if you intend to change values of the variables or key mappings.\n\n```vim\n\" Default rules for matching:\nlet g:pear_tree_pairs = {\n            \\ '(': {'closer': ')'},\n            \\ '[': {'closer': ']'},\n            \\ '{': {'closer': '}'},\n            \\ \"'\": {'closer': \"'\"},\n            \\ '\"': {'closer': '\"'}\n            \\ }\n\" See pear-tree/after/ftplugin/ for filetype-specific matching rules\n\n\" Pear Tree is enabled for all filetypes by default:\nlet g:pear_tree_ft_disabled = []\n\n\" Pair expansion is dot-repeatable by default:\nlet g:pear_tree_repeatable_expand = 1\n\n\" Smart pairs are disabled by default:\nlet g:pear_tree_smart_openers = 0\nlet g:pear_tree_smart_closers = 0\nlet g:pear_tree_smart_backspace = 0\n\n\" If enabled, smart pair functions timeout after 60ms:\nlet g:pear_tree_timeout = 60\n\n\" Automatically map \u003cBS\u003e, \u003cCR\u003e, and \u003cEsc\u003e\nlet g:pear_tree_map_special_keys = 1\n\n\" Default mappings:\nimap \u003cBS\u003e \u003cPlug\u003e(PearTreeBackspace)\nimap \u003cCR\u003e \u003cPlug\u003e(PearTreeExpand)\nimap \u003cEsc\u003e \u003cPlug\u003e(PearTreeFinishExpansion)\n\" Pear Tree also makes \u003cPlug\u003e mappings for each opening and closing string.\n\"     :help \u003cPlug\u003e(PearTreeOpener)\n\"     :help \u003cPlug\u003e(PearTreeCloser)\n\n\" Not mapped by default:\n\" \u003cPlug\u003e(PearTreeSpace)\n\" \u003cPlug\u003e(PearTreeJump)\n\" \u003cPlug\u003e(PearTreeExpandOne)\n\" \u003cPlug\u003e(PearTreeJNR)\n```\n\nLicense\n-------\nMIT\n","funding_links":[],"categories":["Vim Script","Vim script"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmsvg%2Fpear-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmsvg%2Fpear-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmsvg%2Fpear-tree/lists"}