All Projects → tmsvg → Pear Tree

tmsvg / Pear Tree

Licence: mit
A Vim auto-pair plugin that supports multi-character pairs, intelligent matching, and more

Projects that are alternatives of or similar to Pear Tree

Vimcompletesme
You don't Complete Me; Vim Completes Me! A super simple, super minimal, super light-weight tab completion plugin for Vim.
Stars: ✭ 752 (+129.97%)
Mutual labels:  viml, vim-plugin, vim-plugins
Vim Todo Lists
Vim plugin for TODO lists
Stars: ✭ 126 (-61.47%)
Mutual labels:  viml, vim-plugin, vim-plugins
Vifm.vim
Vim plugin that allows use of vifm as a file picker
Stars: ✭ 197 (-39.76%)
Mutual labels:  viml, vim-plugin, vim-plugins
vim-inccomplete
Vim plugin for #include directive completion.
Stars: ✭ 14 (-95.72%)
Mutual labels:  vim-plugin, vim-plugins
vim-jsonc
⚠️Deprecated⚠️: Vim syntax highlighting plugin for JSON with C-style line (//) and block (/* */) comments.
Stars: ✭ 52 (-84.1%)
Mutual labels:  vim-plugin, vim-plugins
swifty-vim
⌨️ A Vim plugin for Swift which provides file detection, syntax highlighting, support for compiling and running tests, and optional support for formatting and linting tools.
Stars: ✭ 18 (-94.5%)
Mutual labels:  vim-plugin, vim-plugins
Vim Go
Go development plugin for Vim
Stars: ✭ 14,085 (+4207.34%)
Mutual labels:  viml, vim-plugins
Blamer.nvim
A git blame plugin for neovim inspired by VS Code's GitLens plugin
Stars: ✭ 283 (-13.46%)
Mutual labels:  viml, vim-plugin
VimConfig
Configuration files for Vi-IMproved.
Stars: ✭ 23 (-92.97%)
Mutual labels:  vim-plugin, vim-plugins
vim-tmuxlike
A vim plugin that mimics the actions of tmux. 像操作Tmux一样操作Vim
Stars: ✭ 20 (-93.88%)
Mutual labels:  vim-plugin, vim-plugins
vim-hugo-helper
A small Vim plugin with a set of helpers for Hugo https://gohugo.io
Stars: ✭ 82 (-74.92%)
Mutual labels:  vim-plugin, vim-plugins
vim-phpstan
A Vim plugin for PHPStan - https://github.com/phpstan/phpstan. It calls `phpstan` to do static analysis of your PHP code and displays the errors in Vim's quickfix list.
Stars: ✭ 26 (-92.05%)
Mutual labels:  vim-plugin, vim-plugins
vim-sass-colors
sass/scss/less/css color literal and color variable highlighting (works with imports)
Stars: ✭ 24 (-92.66%)
Mutual labels:  vim-plugin, vim-plugins
filestyle
filestyle is a Vim plugin that highlights unwanted whitespace and characters.
Stars: ✭ 30 (-90.83%)
Mutual labels:  vim-plugin, vim-plugins
8cc.vim
C Compiler written in Vim script
Stars: ✭ 205 (-37.31%)
Mutual labels:  viml, vim-plugin
vim-bettergrep
A better way to grep in vim.
Stars: ✭ 15 (-95.41%)
Mutual labels:  vim-plugin, vim-plugins
bufstop
Fast and efficient buffer switching for Vim
Stars: ✭ 82 (-74.92%)
Mutual labels:  vim-plugin, vim-plugins
Vim Buffet
IDE-like Vim tabline
Stars: ✭ 304 (-7.03%)
Mutual labels:  viml, vim-plugin
Vim Packager
Vim plugin manager that utilizes "jobs" and "pack" features.
Stars: ✭ 197 (-39.76%)
Mutual labels:  viml, vim-plugins
Jshint2.vim
Lightweight, customizable and functional Vim plugin for JSHint integration.
Stars: ✭ 265 (-18.96%)
Mutual labels:  viml, vim-plugin

Pear Tree

A painless, powerful Vim auto-pair plugin.

Purpose

Pear Tree automatically pairs parentheses, quotes, HTML tags, and many other text items based on a simple-to-define set of rules. It also provides pair-wise deletion, newline expansion, and other typical auto-pair features without interfering with Vim's undo or dot-repeat functionality.

Installation

Follow the instructions provided by your plugin manager. Using vim-plug, you would place the following in your vimrc and run :PlugInstall

Plug 'tmsvg/pear-tree'

You can also install Pear Tree manually by placing the files in their appropriate locations in your Vim directory. Remember to run :helptags if you choose this method.

Features

Multi-Character Pair Support

Pear Tree is not limited to pairing single characters like ( with ), { with }, and so on. If you would like to pair, say, /* with */ or <!-- with -->, simply add them to your g:pear_tree_pairs and it will work just as well.

Wildcard Support

A powerful feature of Pear Tree is its support for wildcard string matching. This is particularly useful for HTML tags, wherein there can be strings of some arbitrary length between the < and > characters (e.g. <body>, <ul>, <p class="Foo">).

Dot-Repeatability

Pear Tree allows brace expansion without breaking Vim's dot-repeat or undo functionality. Consider this example:

1  int foo();|
2
3  int bar();

Type <BS> {

1  int foo() {|}
2
3  int bar();

Type <CR>:

1  int foo() {
2      |
3
4
5  int bar();

Note that the closing pair disappears after pressing <CR>. This is required to not break dot-repeat, but it will be automatically restored later.

Next, type return 1; and leave insert mode:

1  int foo() {
2      return 1;
3  }
4
5  int bar();

Finally, move to line 5 and use the . command:

1  int foo() {
2      return 1;
3  }
4
5  int bar() {
6      return 1;
7  }|

Many implementations of this feature cause the . command to only repeat return 1; instead of the entire typing sequence.

However, if you would prefer expansion to behave like other plugins and text editors, you can prevent Pear Tree from erasing the closing string by setting g:pear_tree_repeatable_expand to 0.

Smart Pairing

Pear Tree includes options to intelligently decide when an opening string should be closed, when typing a closing character should move the cursor past an existing closer, and when both characters in a pair should be deleted when pressing backspace. If these options are enabled, Pear Tree will examine the balance of existing pairs to decide what action should be taken. It will choose the action that makes nearby pairs properly balanced, as summarized in the following table:

Before After (smart pairing) After (no smart pairing)
Opener foo(bar|)) foo(bar(|)) foo(bar(|)))
Closer foo(bar(|) foo(bar()|) foo(bar()|
Backspace foo((|) foo(|) foo(|

Smart pairs must be enabled manually.

Usage

Pear Tree's primary features are enabled automatically, but some useful options and mappings must be set manually. Please read :help pear-tree for useful information on how to define your own pairs, use wildcards, customize mappings, and more.

Defaults

Note: The following code is only here to summarize the available options and show what Pear Tree sets them to by default. You only need to copy it to your config if you intend to change values of the variables or key mappings.

" Default rules for matching:
let g:pear_tree_pairs = {
            \ '(': {'closer': ')'},
            \ '[': {'closer': ']'},
            \ '{': {'closer': '}'},
            \ "'": {'closer': "'"},
            \ '"': {'closer': '"'}
            \ }
" See pear-tree/after/ftplugin/ for filetype-specific matching rules

" Pear Tree is enabled for all filetypes by default:
let g:pear_tree_ft_disabled = []

" Pair expansion is dot-repeatable by default:
let g:pear_tree_repeatable_expand = 1

" Smart pairs are disabled by default:
let g:pear_tree_smart_openers = 0
let g:pear_tree_smart_closers = 0
let g:pear_tree_smart_backspace = 0

" If enabled, smart pair functions timeout after 60ms:
let g:pear_tree_timeout = 60

" Automatically map <BS>, <CR>, and <Esc>
let g:pear_tree_map_special_keys = 1

" Default mappings:
imap <BS> <Plug>(PearTreeBackspace)
imap <CR> <Plug>(PearTreeExpand)
imap <Esc> <Plug>(PearTreeFinishExpansion)
" Pear Tree also makes <Plug> mappings for each opening and closing string.
"     :help <Plug>(PearTreeOpener)
"     :help <Plug>(PearTreeCloser)

" Not mapped by default:
" <Plug>(PearTreeSpace)
" <Plug>(PearTreeJump)
" <Plug>(PearTreeExpandOne)
" <Plug>(PearTreeJNR)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].