auto-pairs/README.md

128 lines
2.9 KiB
Markdown
Raw Normal View History

2011-05-22 13:11:23 -04:00
Auto Pairs
==========
Insert or delete brackets, parens, quotes in pair.
Installation
------------
copy plugin/auto-pairs.vim to ~/.vim/plugin
Features
--------
2011-06-09 14:32:17 -04:00
* Insert in pair
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
input: [
output: [|]
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
* Delete in pair
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
input: foo[<BS>
output: foo
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
* Insert new indented line after Return
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
input: {|} (press <CR> at |)
output: {
|
}
2011-05-22 13:11:23 -04:00
* Insert spaces before closing characters
input: {|} (press <SPACE> at |)
output: { | }
2011-06-09 14:32:17 -04:00
* Skip closed bracket.
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
input: []
output: []
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
* Ignore auto pair when previous character is \
2011-05-22 13:11:23 -04:00
2011-06-09 14:32:17 -04:00
input: "\'
output: "\'"
* Fast Wrap
input: |'hello' (press (<M-e> at|)
output: ('hello')
2011-06-09 14:23:47 -04:00
Shortcuts
---------
System Shortcuts:
<CR> : Insert new indented line after return if cursor in blank brackets or quotes.
<BS> : Delete brackets in pair
<M-p> : Toggle Autopairs
2011-06-09 14:23:47 -04:00
<M-e> : Fast Wrap
Optional Shortcuts:
could be turn off by let g:AutoPairsShortcuts = 0
<M-n> jump to next closed bracket.
<M-a> jump to end of line.
<M-o> jump to newline with indented.
2011-05-22 13:11:23 -04:00
Options
-------
* g:AutoPairs
Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}
* g:AutoPairsShortcutToggle
Default: '<M-p>'
The shortcut to toggle autopairs.
2011-05-22 13:11:23 -04:00
2011-06-09 14:23:47 -04:00
* g:AutoPairsShortcutFastWrap
Default: '<M-e>'
Fast wrap the word. all pairs will be consider as a block (include <>).
(|)'hello' after fast wrap at |, the word will be ('hello')
(|)<hello> after fast wrap at |, the word will be (<hello>)
2011-05-22 13:11:23 -04:00
* g:AutoPairsShortcuts
Default: 1
2011-05-22 13:11:23 -04:00
imap 3 shortcuts
<M-n> jump to next closed bracket.
<M-a> jump to end of line.
<M-o> jump to newline with indented.
* g:AutoPairsMapBS
Default : 1
Map <BS> to delete brackets, quotes in pair
execute 'inoremap <buffer> <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
* g:AutoPairsMapCR
Default : 1
Map <CR> to insert a new indented line if cursor in (|), {|} [|], '|', "|"
execute 'inoremap <buffer> <silent> <CR> <C-R>=AutoPairsReturn()<CR>'
* 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 <space> to insert a space after the opening character and before the closing one.
execute 'inoremap <buffer> <silent> <CR> <C-R>=AutoPairsReturn()<CR>'
2011-05-22 13:11:23 -04:00
TroubleShooting
---------------
The script will remap keys ([{'"}]) <BS>,
If auto pairs cannot work, use :imap ( to check if the map is corrected.
The correct map should be <C-R>=AutoPairsInsert("\(")<CR>
Or the plugin conflict with some other plugins.
use command :call AutoPairsInit() to remap the keys.