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

Does not switch back to relative when exiting insert mode with ^C #30

Open
RatanRSur opened this Issue Jul 29, 2015 · 6 comments

Comments

Projects
None yet
5 participants
@RatanRSur
Copy link

RatanRSur commented Jul 29, 2015

No description provided.

@RatanRSur RatanRSur closed this Oct 2, 2015

@googlebleh

This comment has been minimized.

Copy link

googlebleh commented Dec 11, 2018

Why was this issue closed? I'm still observing this problem with the latest version.

@RatanRSur

This comment has been minimized.

Copy link
Author

RatanRSur commented Dec 11, 2018

I think ^C does not actually allow the plugin to do anything, taking you back to insert mode immediately.

Use:
inoremap <C-c> <Esc>

@jeffkreeftmeijer

This comment has been minimized.

Copy link
Owner

jeffkreeftmeijer commented Dec 12, 2018

Hey both! Missed this one back in 2015. I don't use ^C to get out of insert mode, so I never noticed this isn't working, but I can reproduce this.

Using ^C doesn't seem to trigger the InsertLeave autocommand event, which is causing this. Aside from @RatanRSur's remap, I don't know how to fix it in numbertoggle, but I'd love a pull request if anyone has a great idea.

@googlebleh

This comment has been minimized.

Copy link

googlebleh commented Dec 12, 2018

Thanks to both of you for being so responsive to an old issue!

Just to explain why @RatanRSur's suggestion alone wouldn't work for me: I use ^C because of the lag Esc causes when leaving insert mode. I'd have to also set noesckeys in order for remapping ^C to be sufficient. That's fine for me, but someone else may not want to.

So there is some practical need to find another way to hook ^C. I'll keep an eye out for other ideas.

@AndrewRadev

This comment has been minimized.

Copy link

AndrewRadev commented Jan 26, 2019

One way would be to listen to CursorHold and/or CursorMoved, both of which get triggered in normal mode and not in insert mode. But you'd have to test it out in terms of performance. A check for a global variable's value should be fast enough. Say, on every cursor move/hold, if g:numbertoggle_mode != 'normal' | :set ... | let g:numbertoggle_mode = 'normal' | endif

Alternatively, the plugin could inoremap <silent> <c-c> :numbertoggle#CtrlC()<cr>.

That's fine for me, but someone else may not want to.

It could be an explicit setting for people to opt into. Using <c-c> for exiting normal mode seems like it'd be rare, so might be fine for @googlebleh and any other users to do a little bit of extra work.

@matthsims

This comment has been minimized.

Copy link

matthsims commented Feb 8, 2019

Using <C-c> to exit insert mode intentionally does not trigger the InsertLeave autocommand, and consequently this should not be changed. See :h i_CTRL-C. Triggering it on movement, I imagine, is fine too. Just seems excessive since it fixes itself pretty easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment