Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 1.0.3
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 120 lines (78 sloc) 2.783 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
This is a mirror of http://www.vim.org/scripts/script.php?script_id=3599

Responsitory: https://github.com/jiangmiao/auto-pairs

Auto Pairs
==========
Insert or delete brackets, parens, quotes in pair.

Installation
------------
copy plugin/auto-pairs.vim to ~/.vim/plugin

Features
--------
* Insert in pair
     
        input: [
        output: [|]

* Delete in pair
     
        input: foo[<BS>
        output: foo

* Insert new indented line after Return

        input: {|} (press <CR> at |)
        output: {
            |
        }

* Skip closed bracket.

        input: []
        output: []

* Ignore auto pair when previous character is \

        input: "&#039
        output: "&#039"

* Fast Wrap

        input: |'hello' (press (<M-e> at|)
        output: ('hello')


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
        <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.

Options
-------
* g:AutoPairs

        Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}

* g:AutoPairsShortcutToggle

        Default: '<M-p>'

        The shortcut to toggle autopairs.

* 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>)

* g:AutoPairsShortcuts

        Default: 1

        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.

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.

Something went wrong with that request. Please try again.