jiangmiao / auto-pairs Goto Github PK
View Code? Open in Web Editor NEWVim plugin, insert or delete brackets, parens, quotes in pair
Home Page: http://www.vim.org/scripts/script.php?script_id=3599
Vim plugin, insert or delete brackets, parens, quotes in pair
Home Page: http://www.vim.org/scripts/script.php?script_id=3599
From the documentation, it seems after hitting enter after creating a pair of curly-brackets, the trailing bracket should be on its own line, with the cursor indented on the previous (new) line, for example:
{(enter)}
produces
{
(tab or spaces)||
}
However, I do not see any indentation when I try this.
For example, let's say you have the following text:
def nested_tuple():
return (
(
'a', 'b',
)
)
Now delete the penultimate closing paren in nomal mode:
def nested_tuple():
return (
(
'a', 'b',
)
If you enter insert mode and try to re-add the inner closing paren where it was before, auto-pairs will instead "pass over" the outer paren, forcing you to type )
twice.
Hello,
I'm using a lot auto-completion with omnicompletion and Valloric/YouCompleteMe but auto-pairs actually don't close the auto-inserted (. How do I fix this problem or is there a simple patch ?
This is in Perl but I guess it is a more general problem.
What I want to end up with:
if () {
} elsif () {
}
However if you get to this point (cursor indicated by | )
if () {
} elsif (){|}
and hit ENTER, you get this:
if () {
}
|
elsif () {
}
i.e. the elsif is placed in a new line and the cursor is above it. What I would have expected is to have the cursor in the indented elsif block.
It works if you avoid the lone closing bracket at beginning of line, i.e. starting like this
if () {
}
elsif () {|}
hitting ENTER now produces
if () {
}
elsif () {
}
but the above (top of page) version with the closing bracket at the beginning of the line followed by elsif is a frequently used coding style in Perl, so this should work.
Thanks for looking into this and thanks for providing this very useful plugin!
I would like to auto pair certain typographer's quote pairs, specifically ‘
with ’
and “
with ”
.
The following is in my .vimrc:
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`', '‘':'’','“':'”','«':'»'}
The French style quotes «
and »
auto pair, but the other two additions (‘ ’ “ ”
) do not.
The unicode codes involved:
«
and »
are U+00AB
and U+00BB
(these work)‘
and ’
are U+2018
and U+2019
(do not work)”
and ”
are U+201C
and U+201D
(do not work)I use vim for Objective-C
programming... I was wondering if auto-pairs can be disabled for the [
and ]
characters.
Cheers and thanks for this plug-in 👍
In javascript with nocindent, the indentation is "wrong".
Firstly without auto-pairs plugin:
// cindent
function () {
var foo = {
bar: {
} // this line is not indented "correctly"
}
}
// nocindent
function () {
var foo = {
bar: {
} // ok
}
}
With auto-pairs and nocindent the result is like setting cindent.
I think it is due to '=ko' in line 369:
return "\<ESC>=ko".cmd
https://github.com/jiangmiao/auto-pairs/blob/master/plugin/auto-pairs.vim#L369
Any thought?
Thanks in advance,
Alberto
I have been facing an issue that when I type â, like in the word "Parâmetro", either the cursor jumps somewhere else in the file, or the â is just not inserted and I see only "Parmetro". If I do Ctrl-V â then it works. Strangely, typing any other ^ combination, like
"você", û, ô, etc., it works just fine.
There has been a discussion about this issue in vim_use google groups:
https://groups.google.com/forum/?fromgroups=#!topic/vim_use/rDgZc-az5I4
Your plugin is amazing. Keep up the good work. Thanks.
Pressing enter in insert mode inserts the following text
<SNR>22_HandlePossibleSelectionEnter()
This problem is faced only when I use auto-pairs along with clang-complete
I'm having issues using auto-pairs with other plugins (in particular, VimOrganizer and neocomplcache).
For an example of the unexpected behavior, see this StackOverflow question: http://stackoverflow.com/questions/15578554/vim-plugins-calling-a-function-in-insert-mode-inserts-function-signature-into-b
code:
println("a"
when i write the ')',can not do it
if you have supertab, the CR wil be mapped to:
i <CR> & <C-R>=<SNR>83_SelectCompletion(1)<CR><CR><SNR>19_AutoPairsReturn
and if you press {<CR>, it become {<CR><CR>|} (| is the curser), more worse, if you press <CR>, it becomes <CR><CR> :-(
So I had to modify supertab now :-(
function! AutoPairsDelete()
if !b:autopairs_enabled
return a:key <------ returning non existent function parameter!
end
.
.
.
if you have a buffer has content:
abc
ab|
now you press <C-N> to complete word, it becomes abc, (has popup menu of complete words), then press backspace, the text will become:
abc
abAutoPairsDelete()|
change line 290 of auto-pairs.vim from:
execute 'inoremap <buffer> <silent> <expr> <BS> AutoPairsDelete()'
to:
execute 'inoremap <buffer> <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
seems solve this.
Just a suggestion to include `` in the list of default items to be auto-handled. In Markdown (and older shell scripts, I suppose), it would be very helpful to have them auto-closed, and I can't think of a language where you really wouldn't want them to double.
That said, it's easy enough to add them manually, so this is really just a suggested thought, not a defect at all.
Thanks for the library.
👍 👍
我发现的auto-pairs比 delimitMate好很多。比如{
后enter
空行的处理,比其他的插件都好很多,也没发现bug(使用别的插件,撤销后会残留([{)]}
)。(我之前以为这是delimitMate的功劳,才发现自己同时安装了auto-pairs
和delimitMate
,做了对比才知道是auto-pairs
在默默奉献着)
但有一点,所有的“括号类插件”都没有做好:
比如:
(|)
|
代表光标
使用`backspace`删除`(`,`)`也会自动被删掉,但使用`<c-h>`时,`)`却还在。
使用<c-w>
,<c-h>
删除单词或单个字符,比使用backspace
要快捷呢,如果auto-pairs
能支持这两个快捷键的处理就好了。
auto-pairs
is better than delimitMate
English user please read the duplicate Raimondi/delimitMate#127
After switching to the latest version (1.2.9) I'm suddenly unable to insert the Swedish character 'å'. The issue has been replicated over two apple computers, both running MacVim 7.3 snapshot 66 and Vim 7.3 patch 754. The issue appears both in gVim and terminal sessions.
Hi
This is a great script. I think this would be even more nice:
{
||
V
{
}
same with other brackets.
When I use vim html attribute completion I get to situations where the code looks like:
<img src="test.jpg|
and when I hit " to end the attribute auto-pairs enters a second " so the code becomes
<img src="test.jpg"|"
could auto-paris not figure out that I'm already inside a string and just want to close it? I know I can do " but it would be nice if I didn't have to.
Hey,
if space mapping is enabled, abbreviations in insert mode does not work. Is it possible to fix?
I'm having a weird behavior with auto-pairs and the backspace key. It deletes part of the line but if I write something it continues where I was before backspace. The below example is just made up, a better example can be viewed in a screen recording I did and uploaded here: http://d.pr/v/6U87
The video is not very good since it's my first try att screen recording but you can hopefully see what happens. Here is the text version, I start out with a line like this:
Official site of the popular vi clone. Includes project news, documentation.
My cursor is at the end and when I press backspace the line is changed to
Official site of the popular vi
When I write more text it becomes
Official site of the popular vi More text added here
I've disabled all other plugins except auto-pairs and if I disable auto-pairs also it doesn't happend. If I do :imap I get:
i <BS> *@<C-R>=AutoPairsDelete()<CR>
Thanks in advance!
I have this in my .vimrc:
" {{{ Autopairs
autocmd FileType vim let b:AutoPairs={'(':')', '[':']', "'":"'", '`':'`'}
let g:AutoPairsFlyMode = 0
" }}}
If I insert a "
after the fourth line, the cursor jumps to the double-quote mark on the last line. This happens even if I set AutoPairs globally to exclude double-quote marks.
(Sorry, rather a question, than an issue.)
auto-pairs is great, but when writing a VimL file, it's a bit annoying that "
always gets auto-paired. How do I disable auto-pairing "
just for VimL?
I read the documentation, but couldn't figure out.
I'm not sure if this is even fixable (and I've faced similar issues with other pairing plugins), but could it possibly be made to work with '.'.
Currently if I type ''i[Hello world]' and then hit '.' I only get the 'Hello World' and not the brackets. I understand they work as different actions, but unfortunately vim users are used to thinking of an insert action as a repeatable command.
This becomes even more tricky if you use this as part of a 'cw' (change word) type command, because it forgets the changing part of the action.
Hi there
I couldn't find a license mentioned. Can you please add one so one knows whether it is legal to fork or package it for a Linux distribution (for example)?
Thanks!
in gvim im having errors with "
error says:
E116: Invalid arguments for function AutoPairsInsert(""")
E15: Invalid expression: AutoPairsInsert(""")
my plugin installed:
pathogen
zencoding
NERDTree
I noticed that vim's internal abbreviations are not working once auto-pairs is installed. I had the same issue in the past the auto-close. I guess it's how those plugins are implemented.
Any chance to might figure out a workaround?
使用了auto-pairs插件后,无法输入中文,切换到中文输入法打字时会自动换回英文
I like your auto-pairs mode very much. It just "works" enough that I rarely think about it.
However, it does ruin the the .
command. Typing anything with a pair in it will produce weird results with the .
command.
@tpope has vim-repeat which allows (allegedly) plugin writers to easily support the .
command. I don't know how easy it is, since I don't grok how it works or how to add it to your code.
But I'd really appreciate it if auto-pairs worked with the .
command.
Thanks!
我做了这样的设置:
let g:AutoPairsShortcutJump = '<C-k>'
但遗憾地是它会把我在其他模式下的 <C-k>
覆盖掉,我尝试了使用 i_<C-k>
或 i_<CTRL-k>
这样的写法都没有效果。
请问如何指定模式下修改映射快捷键?
Hi,
First of all thanks for the plugin. Great stuff.
In OS X I can use the following combo to obtain an "á" character:
<opt>-e a
(opt+e pressed together followed by an 'a' )
However when using auto-pairs this combo doesn't work.
I created a short screencast showing the issue.
http://f.cl.ly/items/0q211w1I0d050V2K2k0j/auto-pairs-accent-bug.mov
Thanks in advance.
Cheers!
When I've set filetype plugin indent on
and am writing a nested paren/bracket/etc., the closing bracket doesn't indent properly after hitting enter.
This is true for both CSS and JavaScript (haven't tested others).
Screencast attached:
http://f.cl.ly/items/3w3E2Z1h1z3O3H3l3T2b/autopairindent.mov
Relevant .vimrc settings in this screencast:
filetype plugin indent on
set autoindent
set smartindent
And the filetype is set to css
here.
Normally if you enter Insert-mode, everything from entering the mode until you return to Normal-mode is stored as one change.
After bisecting I've determined that 207107a has the effect of breaking up these monolithic changes into lots of small ones, effectively flooding the undo list.
I'm using MacVim and trying to press ENTER
just after a pair creation to produce, e.g.
(
)
gives the following error:
The problem is in this line:
if g:AutoPairsCenterLine && winline() * 1.5 >= winheight(0)
VIM help says those functions return a Number
and says the following about Float
/Number
conversions:
When mixing Number and Float the Number is converted to Float. Otherwise
there is no automatic conversion of Float. You can use str2float() for String
to Float, printf() for Float to String and float2nr() for Float to Number.
I've changed that line to this:
if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
and it's not giving errors anymore.
OFF TOPIC:
I'm a MacVim user and some default auto-pairs shortcuts has made me go through this.
Is it possible to add the above described functionality, namely: while writing some JavaScript code I often have to write anonymous functions, like
EmployeeProvider.prototype.findById = function(id, callback){
|
};
(let say the cursor is where |
is )
Besides closing the brace and putting a line of gap between it would be really cool to put ;
after }
.
P.S.
Love this plugin :)
I have noticed that with your plugin using Insert new indented line after Return
in e.g. ({ | })
I would get wrong indentation level.
mydata.forEach(function(d){
d.interval = +d.interval;
})
How this can be corrected or adjusted to produce something like this :
mydata.forEach(function(d){
d.interval = +d.interval;
})
??
Fast Wrap 目前的行為: ( | 是 caret 的位置)
Before: (|)p[i]; fast wrap once: (p[|)i]; fast wrap twice: (p[i];|)
原本預期是這樣:
Before: (|)p[i]; fast wrap once: (p|)[i]; fast wrap twice: (p[i]|);
I'm using neocomplcache, neocomplcache complete function like this aa.func(
, I hope auto pairs can work here.
I posted an issue at neocomplcache repo, someone told me, this should be implemented by autopairs.
82_CR() ...
Because both AutoPairs and vim-endwise remap <CR>
, one or the other mapping gets clobbered.
There's a parallel issue over on vim-endwise's repo, and I've tried to point to some possible help there: tpope/vim-endwise#19.
Any thoughts or suggestions you have would be appreciated.
Hi jiangmiao,
I know this is not your script's fault but I was wondering if you maybe have a solution for it or if it would be possible to even modify your script to avoid this problem?
I am using viki/Deplate (http://www.vim.org/scripts/script.php?script_id=861)
and just noticed that auto-pairs causes a serious issue in viki, probably because of the remapping of ?
When I have auot-pairs in my plugin folder and open a page in viki then whenever I hit ENTER, I get this:
viki#ExprMarkInexistentInElement('ParagraphVisible','
')
I don't know how to explore further what is going on and whether there could be a workaround. I tried toggling auto-pairs in viki files but even when auto-pairs is off I get the above problem. It only goes away if I remove auto-pairs from the plugin folder.
auto-pairs used to be able to work with iabbre. But now it breaks iabbre. I forgot from which version this problem began to occur. I noticed that many automatic-paren-closing plugins have the same problem. If the author confirms this is a won't-fix, it is absolutely all right to close this ticket immediately.
Take the following vim script code:
" This is a comment
Cursor is somewhere on the line above. Open new line above with . Result:
"<cursor here>
" This is a comment
Press backspace to delete the " (quote) at the beginning of the line. Result:
This is a comment
The " (quote) in the commented out line was removed in addition to the " (quote) intended to be removed.
I.e. if the text is like below:
(|
()
and | is the curser. when you press ), mustly you mean close the first bracket, but in face you jumpped to second ).
maybe we can check the next ) before jump.
thank you :-)
if you have supertab, the CR wil be mapped to:
i & =83_SelectCompletion(1)19_AutoPairsReturn
and if you press {, it become {|} (| is the curser), more worse, if you press , it becomes :-(
So I had to modify supertab now :-(
The CR mapping seems to conflict with supertab (https://github.com/ervandew/supertab). When pressing CR in insert mode I get this error:
E15: Invalid expression: ^R=<80>R11_SelectCompletion(1)^M
I've installed the latest github versions of both plugins, and only these an pathogen.
(I opened an issue for supertab too as I'm not sure if the problem is best solved here or there: ervandew/supertab#69)
I hope AutoPairs can support a function for key map to jump out pairs directly.
For example:
print('This is text|')
--> jump out --> print('This is text')|
The cursor |
can jump out quickly.
This keymap can be <Tab>
or <C-*>
etc.
In a markdown file, instead of creating a new line when the return key is pressed, auto-pairs spits out <SNR>57_Return()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.