Skip to content

Commit 587fca3

Browse files
jiangmiaovim-scripts
authored andcommitted
Version 1.2.0: New feature: Fly Mode
1 parent efd24ce commit 587fca3

File tree

3 files changed

+195
-41
lines changed

3 files changed

+195
-41
lines changed

README

Lines changed: 92 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ copy plugin/auto-pairs.vim to ~/.vim/plugin
1313
Features
1414
--------
1515
* Insert in pair
16-
16+
1717
input: [
1818
output: [|]
1919

2020
* Delete in pair
21-
21+
2222
input: foo[<BS>
2323
output: foo
2424

@@ -40,6 +40,11 @@ Features
4040
input: '|' (press <SPACE> at |)
4141
output: ' |'
4242

43+
* Skip ' when inside a word
44+
45+
input: foo| (press ' at |)
46+
output: foo'
47+
4348
* Skip closed bracket.
4449

4550
input: []
@@ -56,8 +61,8 @@ Features
5661
output: ('hello')
5762

5863
* Quick jump to closed pair.
59-
60-
input:
64+
65+
input:
6166
{
6267
something;|
6368
}
@@ -69,26 +74,82 @@ Features
6974

7075
}|
7176

77+
* Support ``` ''' and """
78+
79+
input:
80+
'''
81+
82+
output:
83+
'''
84+
85+
* Fly Mode
86+
87+
input: if(a[3)
88+
output: if(a[3])| (In Fly Mode)
89+
output: if(a[3)]) (Without Fly Mode)
90+
91+
input:
92+
{
93+
hello();|
94+
world();
95+
}
96+
97+
(press } at |)
98+
99+
output:
100+
{
101+
hello();
102+
world();
103+
}|
104+
105+
(then press <M-b> at | to do backinsert)
106+
output:
107+
{
108+
hello();}|
109+
world();
110+
}
111+
112+
See Fly Mode section for details
113+
114+
Fly Mode
115+
--------
116+
Fly Mode will always force closed-pair jumping instead of inserting. only for ")", "}", "]"
117+
118+
If jumps in mistake, could use AutoPairsBackInsert(Default Key: <M-b>) to jump back and insert closed pair.
119+
120+
the most situation maybe want to insert single closed pair in the string, eg ")"
121+
122+
Fly Mode is DISABLED by default.
123+
124+
add **let g:AutoPairsFlyMode = 1** .vimrc to turn it on
125+
126+
Default Options:
127+
128+
let g:AutoPairsFlyMode = 0
129+
let g:AutoPairsShortcutBackInsert = '<M-b>'
130+
72131
Shortcuts
73132
---------
74133

75134
System Shortcuts:
76135
<CR> : Insert new indented line after return if cursor in blank brackets or quotes.
77136
<BS> : Delete brackets in pair
78-
<M-p> : Toggle Autopairs
79-
<M-e> : Fast Wrap
137+
<M-p> : Toggle Autopairs (g:AutoPairsShortcutToggle)
138+
<M-e> : Fast Wrap (g:AutoPairsShortcutFastWrap)
139+
<M-n> : Jump to next closed pair (g:AutoPairsShortcutJump)
140+
<M-b> : BackInsert
80141

81-
Optional Shortcuts:
82-
could be turn off by let g:AutoPairsShortcuts = 0
83-
<M-n> jump to next closed bracket.
84-
<M-a> jump to end of line.
85-
<M-o> jump to newline with indented.
142+
If <M-p> <M-e> or <M-n> conflict with another keys or want to bind to another keys, add
143+
144+
let g:AutoPairShortcutToggle = '<another key>'
145+
146+
to .vimrc, it the key is empty string '', then the shortcut will be disabled.
86147

87148
Options
88149
-------
89150
* g:AutoPairs
90151

91-
Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}
152+
Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'}
92153

93154
* g:AutoPairsShortcutToggle
94155

@@ -97,21 +158,18 @@ Options
97158
The shortcut to toggle autopairs.
98159

99160
* g:AutoPairsShortcutFastWrap
100-
161+
101162
Default: '<M-e>'
102163

103164
Fast wrap the word. all pairs will be consider as a block (include <>).
104165
(|)'hello' after fast wrap at |, the word will be ('hello')
105166
(|)<hello> after fast wrap at |, the word will be (<hello>)
106167

107-
* g:AutoPairsShortcuts
168+
* g:AutoPairsShortcutJump
108169

109-
Default: 1
170+
Default: '<M-n>'
110171

111-
imap 3 shortcuts
112-
<M-n> jump to next closed bracket.
113-
<M-a> jump to end of line.
114-
<M-o> jump to newline with indented.
172+
Jump to the next closed pair
115173

116174
* g:AutoPairsMapBS
117175

@@ -140,9 +198,22 @@ Options
140198
Map <space> to insert a space after the opening character and before the closing one.
141199
execute 'inoremap <buffer> <silent> <CR> <C-R>=AutoPairsSpace()<CR>'
142200

201+
* g:AutoPairsFlyMode
202+
203+
Default : 0
204+
205+
set it to 1 to enable FlyMode.
206+
see FlyMode section for details.
207+
208+
* g:AutoPairsShortcutBackInsert
209+
210+
Default : <M-b>
211+
212+
Work with FlyMode, insert the key at the Fly Mode jumped postion
213+
143214
TroubleShooting
144215
---------------
145-
The script will remap keys ([{'"}]) <BS>,
216+
The script will remap keys ([{'"}]) <BS>,
146217
If auto pairs cannot work, use :imap ( to check if the map is corrected.
147218
The correct map should be <C-R>=AutoPairsInsert("\(")<CR>
148219
Or the plugin conflict with some other plugins.
@@ -158,3 +229,4 @@ TroubleShooting
158229
2. use Alt-P to turn off the plugin.
159230

160231
3. use DEL or <C-O>x to delete the character insert by plugin.
232+

README.md

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ copy plugin/auto-pairs.vim to ~/.vim/plugin
99
Features
1010
--------
1111
* Insert in pair
12-
12+
1313
input: [
1414
output: [|]
1515

1616
* Delete in pair
17-
17+
1818
input: foo[<BS>
1919
output: foo
2020

@@ -57,8 +57,8 @@ Features
5757
output: ('hello')
5858

5959
* Quick jump to closed pair.
60-
61-
input:
60+
61+
input:
6262
{
6363
something;|
6464
}
@@ -78,6 +78,47 @@ Features
7878
output:
7979
'''
8080

81+
* Fly Mode
82+
83+
input: if(a[3)
84+
output: if(a[3])| (In Fly Mode)
85+
output: if(a[3)]) (Without Fly Mode)
86+
87+
input:
88+
{
89+
hello();|
90+
world();
91+
}
92+
93+
(press } at |)
94+
95+
output:
96+
{
97+
hello();
98+
world();
99+
}|
100+
101+
(then press <M-b> at | to do backinsert)
102+
output:
103+
{
104+
hello();}|
105+
world();
106+
}
107+
108+
See Fly Mode section for details
109+
110+
Fly Mode
111+
--------
112+
113+
Fly Mode will always force closed-pair jumping instead of inserting. only for ")", "}", "]"
114+
If jumps in mistake, could use AutoPairsBackInsert(Default Key: <M-b>) to jump back and insert closed pair.
115+
the most situation maybe want to insert single closed pair in the string, eg ")"
116+
117+
Default Options:
118+
119+
let g:AutoPairs_FlyMode = 1
120+
let g:AutoPairsShortcutBackInsert = '<M-b>'
121+
81122
Shortcuts
82123
---------
83124

@@ -87,10 +128,11 @@ Shortcuts
87128
<M-p> : Toggle Autopairs (g:AutoPairsShortcutToggle)
88129
<M-e> : Fast Wrap (g:AutoPairsShortcutFastWrap)
89130
<M-n> : Jump to next closed pair (g:AutoPairsShortcutJump)
131+
<M-b> : BackInsert
90132

91133
If <M-p> <M-e> or <M-n> conflict with another keys or want to bind to another keys, add
92134

93-
let g:AutoPairscutToggle = '<another key>'
135+
let g:AutoPairShortcutToggle = '<another key>'
94136

95137
to .vimrc, it the key is empty string '', then the shortcut will be disabled.
96138

@@ -107,7 +149,7 @@ Options
107149
The shortcut to toggle autopairs.
108150

109151
* g:AutoPairsShortcutFastWrap
110-
152+
111153
Default: '<M-e>'
112154

113155
Fast wrap the word. all pairs will be consider as a block (include <>).
@@ -147,9 +189,21 @@ Options
147189
Map <space> to insert a space after the opening character and before the closing one.
148190
execute 'inoremap <buffer> <silent> <CR> <C-R>=AutoPairsSpace()<CR>'
149191

192+
* g:AutoPairsFlyMode
193+
194+
Default : 1
195+
196+
see FlyMode section for details.
197+
198+
* g:AutoPairsShortcutBackInsert
199+
200+
Default : <M-b>
201+
202+
Work with FlyMode, insert the key at the Fly Mode jumped postion
203+
150204
TroubleShooting
151205
---------------
152-
The script will remap keys ([{'"}]) <BS>,
206+
The script will remap keys ([{'"}]) <BS>,
153207
If auto pairs cannot work, use :imap ( to check if the map is corrected.
154208
The correct map should be <C-R>=AutoPairsInsert("\(")<CR>
155209
Or the plugin conflict with some other plugins.

0 commit comments

Comments
 (0)