0

I'm aware that if I press esc followed by typing :q!, I can exit the vim editor, due to this question.

However, the standard convention is for programs to exit when ctrl + c is pressed, which sends a SIGINT to the currently running process.

For example, top, tail -f, and ping all follow this convention.

My question is this: Why doesn't vim follow this well-established convention? Is there a historical reason, or is it something else?

It seems to me that it would avoid a lot of confusion for new users if it followed this standard convention like everything else.

(While we're at it, why is it SIGINT and not SIGTERM in the first place?)

3
  • 3
    Vim likely does it because vi does it. Vi likely does it because ex does it. Ex likely does it because ed did it. Jun 14, 2019 at 18:00
  • 1
    @MarkPlotnick And ed does it because doing it is the standard convention for Ctrl+C: to return to the toplevel loop. In interactive programs, the toplevel loop is not the shell. And that's part of why there's SIGINT and SIGTERM: SIGINT goes to the toplevel loop, SIGTERM terminates the program and returns to the shell. Jun 14, 2019 at 18:02
  • Ah, that makes sense @Gilles! I didn't find that question that this one has been marked a duplicate of when I searched. Jun 18, 2019 at 19:58

1 Answer 1

4

My question is this: Why doesn't vim follow this well-established convention? Is there a historical reason, or is it something else?

Because vim is following another old and well-established convention, where Control-C inside an interactive program will abort the current command, not the whole program. This convention is also followed by interactive shells -- a Control-C will not kill your shell, but the command it was running or going to run.

Programs which don't follow that convention usually try to palliate the horror by catching the SIGINT and asking the user "do you really want to quit", or "use quit to exit", etc, which turns them from nasty to annoying.

Other very well established conventions for Control-C are to use it as a prefix for other commands (as in emacs-inspired programs, where Control-G takes the role of Control-C) or to copy the selection to the clipboard.

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.