Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exiting insert mode adds char at EOL #81

Closed
spodernet opened this issue Sep 1, 2016 · 7 comments
Closed

Exiting insert mode adds char at EOL #81

spodernet opened this issue Sep 1, 2016 · 7 comments

Comments

@spodernet
Copy link

spodernet commented Sep 1, 2016

Like the title says and as this gif shows exiting Insert mode using the ESC key causes a char to be added at the end of line. It happens with other functions too, like malloc().

Another example is if I use xptemplate to write printf("%d\n", (3+2)); It causes a ')' to be added after the ';', giving me printf("%d\n", (3+2));)

If I manually type it (without using xptemplate) it behaves like usual. No extra char is added.

vimrc: http://nopaste.linux-dev.org/?1119832

@drmingdrmer
Copy link
Owner

OK let me test with your vimrc. since I did not experience something like this, do you have any plugin installed that might change user-typing behaviors?

@drmingdrmer
Copy link
Owner

yeah. I see a list of plugins in your .vimrc:)

@drmingdrmer
Copy link
Owner

I tried several times but failed to reproduce this issue with all your plugins or with only xptemplate enabled.

What is the exact key sequence you typed to produce the result in the gif? Sorry in the gif it is not very clear what you typed.

I tested it on my macbook, with VIM 7.4 Included patches: 1-2152 . what is your VIM version?

@spodernet
Copy link
Author

spodernet commented Sep 3, 2016

So the key sequence is: press i to enter insert mode, then type print and press <C-\> to trigger xptemplate, so I get printf("pattern") with pattern focused. Then I type ℅s\n, result is printf("℅s\n") then I press <tab> to trigger xptemplate again and get printf("℅s\n", a_string) with a_string focused, then I type "abc"; I press <tab> again to go after ')', I finally type ; and press <ESC>. After esc is pressed a " appears after ;.

I've tried running vim with no plugins (vim -u NONE) and running vim without xptemplate and typing the whole thing manually and I can't reproduce it. I can only reproduce it when xptemplate is enabled and I use it to auto complete.
Another thing that I tried is binding ESC to another key like jk. When I use jk to exit insert mode, it behaves like it should, if I use <esc> I get this strange behaviour.

Vim version is the latest offered by arch Linux: 7.4.2143-1

@drmingdrmer
Copy link
Owner

I believe it is definitely an issue with Plugin 'Townk/vim-autoclose', in your vimrc at 74 line.
The key sequence to produce it is:

print<C-\>
%s<Tab>
"abc<Tab>  // here do not type the right quote mannually.
;<Esc> // there will be a double quote appear.

If you manually close the quotes around abc, there won't be such problem.

I will have a deeper look at vim-autoclose. Maybe I can fix it in xptemlate or maybe a patch to vim-autoclose is required.

By the way. xptemplate provides quote/bracket auto-completion mechanism. Just add this to your vimrc:

let g:xptemplate_brace_complete = '(['

@drmingdrmer
Copy link
Owner

I found that adding this line to vimrc removes this issue:

let g:AutoClosePreserveDotReg = 0

Obviously vim-autoclose does not deal with cursor-moving in INSERT mode very well. It assumes when ESC pressed cursor is always before a quote or bracket.

I posted an issue to vim-autoclose describing how to reproduce this issue, maybe the author has a better way to solve this. Townk/vim-autoclose#72

@spodernet
Copy link
Author

Thanks for finding the real issue, hopefully the author can fix it, otherwise I'll deal with it by using the workaround or by using something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants