How do I get out of a messy merge when using vimdiff

Viewed 170

I use vimdiff as my merge tool in mercurial. Sometimes I'll start a rebase that ends up being pretty messy and I just want to try and get out of the process and do something different. The way I end up doing this is usually just spamming :qa until I've made my way through all the conflicting files, but for larger sets of conflicts this can mean I'm doing that for quite a while. Sometimes, if I'm lucky, I can sneak in Ctrl+C in the time before the next conflict loads up in vim, but often I just end up messing something even bigger up and my whole terminal session is hosed.

Is there a more graceful way of quitting out of a messy rebase when using vimdiff?

2 Answers

From vimdiff, you can use the :cq command to quit Vim with an error code.

Mercurial should be able to tell that this happened and interpret as you telling it to stop the operation, giving you the opportunity to break the merge operation.

You can use Ctrl+Z to suspend the foreground process (which is vimdiff, but also the hg that spawned it), dropping you back to the shell.

At this point, you can kill the foreground job with kill %%, or perhaps kill -INT %% (SIGINT is equivalent to pressing Ctrl+C), which should kill the hg process and terminate vimdiff with a SIGHUP (Hang-Up).

By suspending vimdiff, you manage to find the time to send hg the equivalent of a Ctrl+C.

Related