Pressing Ctrl-C with multiple cursors selected leaves editor in weird state
Firstly, massive kudos for bringing this project to Vim. I'm hoping to help and contribute when I get time, but until then I'll file some issues just so they are recorded and somebody else may be able to fix them.
If you select multiple cursors, then press Ctrl-C, you'd expect the cursors to go away, much like pressing ESC. This is what happens when you are in visual mode and you press Ctrl-C. Instead, with multiple cursors what happens is all the cursors remain marked, even though they're not really active anymore. Pressing ESC at this point does nothing, and the only way to clear them is to do: Ctrl-n, ESC.
+1
Pressing C-c in multicursor's visual mode works as expected. Every virtual cursor will go back to normal mode, this is consistent with Vim's behavior.
Pressing C-c in multicursor's normal mode breaks with the default setting like you described above. If you want C-c to quit multicursor's normal mode and go back to Vim's normal mode and clears all virtual cursors, you can map the g:multi_cursor_quit_key to <C-c>. This of course isn't ideal since <Esc> will no longer work to quit multicursor mode. It sounds like what you want is the ability to assign multiple keys to quit multicursor mode. Would that address your issue? Something like
let g:multi_cursor_quit_keys='<Esc>,<C-c>'
Seems like that might be a sensible default, if it were possible? ;) Usually C-c just aborts whatever operation you're in the middle of, so if that's using multi-cursors, I'd expect it go back into "normal" (actual normal) mode. Allowing multiple key bindings would work well too though, yes. I could technically map C-c to <ESC> locally, but that causes other problems.
+1 for making this default, I came here after googling for this same issue.
with @faceleg and @d11wtq on this one, came here after googling as well <esc> is too far away to use for quitting :) also <c-n> <esc> does not clear the cursors.
Still a no go on this?
:+1: Any fix coming up for this?
@terryma, As I understand it, there is a subtle difference between ctrl-c and esc:
ctrl-c can be used for "go back to normal mode", but is a variation more akin to "abort": e.g. http://stackoverflow.com/questions/5030164/whats-the-difference-between-ctrlc-and-ctrl, :help CTRL-C, and :help i_CTRL-C.
It's esc and its equivalent, ctrl-], that's "go back to normal mode": e.g. :help i_CTRL-[, help c_Esc, :help mode-switching, :help escape.
I actually found myself in this issues section because I discovered ctrl-] didn't work, for which I've created issue https://github.com/terryma/vim-multiple-cursors/issues/82
This is an issue that is getting in my way. I don't understand the inner technicalities, but:
I use <ctrl-c> as a way to get out of insert mode. Frankly, I'd like it to be a way to get out of any special mode.
I also see this was filed as an "enhancement". While this may or may not require refactoring, it does run contrary to the behavior that an end-user would expect.
Would it help if the function to quit out of highlighting was made public? I tried giving it a shot in https://github.com/terryma/vim-multiple-cursors/pull/126.
While the PR you submitted does seem to let me quit multi cursor mode with <C-c>, it leaves the editor with the previous selections still visible.
I also notice this same problem. The behavior in my PR is flawed and it should probably be reverted. I have tried various approaches but could not find a way to clear previous selections.
In vanilla, how does esc trigger the desired behaviour?
According to Vim's documentation, Ctrl+C does not check for abbreviations and does not trigger the InsertLeave autocommand event while Ctrl+[ does.
From http://stackoverflow.com/a/80761/187954
Can one trigger autocommands manually? i.e. could we just add a InsertLeave firing to the public function you added?
Maybe with :do? http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-execute
This seems to work for me:
let g:multi_cursor_quit_key='
' nnoremap :call multiple_cursors#quit()
As found on the README, on the bottom of this section:
https://github.com/terryma/vim-multiple-cursors#mapping
~~multiple_cursors#quit() doesn't appear to be a callable function~~ My bad, wrong git page