Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vim-scripts/Auto-Pairs
Insert or delete brackets, parens, quotes in pair.
https://github.com/vim-scripts/Auto-Pairs
Last synced: 30 days ago
JSON representation
Insert or delete brackets, parens, quotes in pair.
- Host: GitHub
- URL: https://github.com/vim-scripts/Auto-Pairs
- Owner: vim-scripts
- Created: 2011-06-03T00:26:52.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-08-12T04:11:18.000Z (almost 11 years ago)
- Last Synced: 2024-02-17T10:37:21.024Z (4 months ago)
- Language: VimL
- Homepage: http://www.vim.org/scripts/script.php?script_id=3599
- Size: 85.9 KB
- Stars: 62
- Watchers: 7
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README
Lists
- maximum-awesome-squared - auto-pairs
README
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3599
Repository: https://github.com/jiangmiao/auto-pairs
Auto Pairs
==========
Insert or delete brackets, parens, quotes in pair.Installation
------------
copy plugin/auto-pairs.vim to ~/.vim/pluginor if you are using `pathogen`:
```git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs```
Features
--------
* Insert in pairinput: [
output: [|]* Delete in pair
input: foo[
output: foo* Insert new indented line after Return
input: {|} (press at |)
output: {
|
}* Insert spaces before closing characters, only for [], (), {}
input: {|} (press at |)
output: { | }input: {|} (press foo} at |)
output: { foo }|input: '|' (press at |)
output: ' |'* Skip ' when inside a word
input: foo| (press ' at |)
output: foo'* Skip closed bracket.
input: []
output: []* Ignore auto pair when previous character is \
input: "'
output: "'"* Fast Wrap
input: |'hello' (press ( at |)
output: ('hello')wrap string, only support c style string
input: |'h\\el'lo' (press ( at |)
output ('h\\ello'')input: |[foo, bar()] (press ( at |)
output: ([foo, bar()])* Quick jump to closed pair.
input:
{
something;|
}(press } at |)
output:
{}|
* Support ``` ''' and """
input:
'''output:
'''|'''* Delete Repeated Pairs in one time
input: """|""" (press at |)
output: |input: {{|}} (press at |)
output: |input: [[[[[[|]]]]]] (press at |)
output: |* Fly Mode
input: if(a[3)
output: if(a[3])| (In Fly Mode)
output: if(a[3)]) (Without Fly Mode)input:
{
hello();|
world();
}(press } at |)
output:
{
hello();
world();
}|(then press at | to do backinsert)
output:
{
hello();}|
world();
}See Fly Mode section for details
Fly Mode
--------
Fly Mode will always force closed-pair jumping instead of inserting. only for ")", "}", "]"If jumps in mistake, could use AutoPairsBackInsert(Default Key: ``) to jump back and insert closed pair.
the most situation maybe want to insert single closed pair in the string, eg ")"
Fly Mode is DISABLED by default.
add **let g:AutoPairsFlyMode = 1** .vimrc to turn it on
Default Options:
let g:AutoPairsFlyMode = 0
let g:AutoPairsShortcutBackInsert = ''Shortcuts
---------System Shortcuts:
: Insert new indented line after return if cursor in blank brackets or quotes.
: Delete brackets in pair
: Toggle Autopairs (g:AutoPairsShortcutToggle)
: Fast Wrap (g:AutoPairsShortcutFastWrap)
: Jump to next closed pair (g:AutoPairsShortcutJump)
: BackInsert (g:AutoPairsShortcutBackInsert)If or conflict with another keys or want to bind to another keys, add
let g:AutoPairShortcutToggle = ''
to .vimrc, if the key is empty string '', then the shortcut will be disabled.
Options
-------
* g:AutoPairsDefault: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'}
* b:AutoPairs
Default: g:AutoPairs
Buffer level pairs set.
* g:AutoPairsShortcutToggle
Default: ''
The shortcut to toggle autopairs.
* g:AutoPairsShortcutFastWrap
Default: ''
Fast wrap the word. all pairs will be consider as a block (include <>).
(|)'hello' after fast wrap at |, the word will be ('hello')
(|) after fast wrap at |, the word will be ()* g:AutoPairsShortcutJump
Default: ''
Jump to the next closed pair
* g:AutoPairsMapBS
Default : 1
Map to delete brackets, quotes in pair
execute 'inoremap =AutoPairsDelete()'* g:AutoPairsMapCR
Default : 1
Map to insert a new indented line if cursor in (|), {|} [|], '|', "|"
execute 'inoremap =AutoPairsReturn()'* g:AutoPairsCenterLine
Default : 1
When g:AutoPairsMapCR is on, center current line after return if the line is at the bottom 1/3 of the window.
* g:AutoPairsMapSpace
Default : 1
Map to insert a space after the opening character and before the closing one.
execute 'inoremap =AutoPairsSpace()'* g:AutoPairsFlyMode
Default : 0
set it to 1 to enable FlyMode.
see FlyMode section for details.* g:AutoPairsShortcutBackInsert
Default :
Work with FlyMode, insert the key at the Fly Mode jumped postion
Buffer Level Pairs Setting
--------------------------Set b:AutoPairs before BufEnter
eg:
" When the filetype is FILETYPE then make AutoPairs only match for parenthesis
au Filetype FILETYPE let b:AutoPairs = {"(": ")"}TroubleShooting
---------------
The script will remap keys ([{'"}]) ,
If auto pairs cannot work, use :imap ( to check if the map is corrected.
The correct map should be =AutoPairsInsert("\(")
Or the plugin conflict with some other plugins.
use command :call AutoPairsInit() to remap the keys.* How to insert parens purely
There are 3 ways
1. use Ctrl-V ) to insert paren without trigger the plugin.
2. use Alt-P to turn off the plugin.
3. use DEL or x to delete the character insert by plugin.
Known Issues
-----------------------
There are the issues I cannot fix.Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3)
Description: After entering insert mode and inputing `[hello` then leave insert
mode by ``. press '.' will insert 'hello' instead of '[hello]'.
Reason: `[` actually equals `[]\` and \ will break '.'
Solution: noneContributors
------------
* [camthompson](https://github.com/camthompson)