Why does Vi have multiple modes? I'm not interested in the functions of the modes unless that was a reason to have different modes. I'm only interested in the design / engineering reasons for multiple modes.

  • Which kind of mode do you mean? ex mode vs. vi mode vs. vim mode? Or command mode vs. insert mode vs. overwrite mode?
    – wallyk
    Commented Jun 29, 2014 at 19:47

2 Answers 2


Considering the primary two modes, COMMAND and INSERT, demonstrates the purpose of a modal interface.

In INSERT mode you can type normally, inserting text into the document. You can bind keys to perform special functions, although these are generally limited in complexity.

COMMAND mode is sort of like an unlimited special function. Something similar could have been implemented using Ctrl, so that you hold down it down and press some other special key, and in fact most generic editors do work that way: you use ctrl-x to cut, ctrl-p to paste, etc. However, this method limits what you can do; it would be a bit of a pain to hold down ctrl and type "open myfile.txt".

GUI editors and some TUI editors usually get around this with drop down menus. However, that's still limited: if you have a lot of features you end up needing awkward cascading nested sets of menus.

vi, which vim is based on (and duplicates the functionality of) does not use drop down menus, although since it is screen based it could have. One explanation for this is that it is intended as a standardized extension of the standardized utility ed, which is line based and therefore cannot use visual menus. Some of the basic vi COMMAND mode commands are derived from ed -- rather than replace a command with a menu option, the same text based ed commands work in vi (and are expanded upon).

There is of course an advantage to all this, and it's probably a major reason for vim's historical popularity. Menus require you to scroll through sets of options, with TUI interfaces sans a mouse, this may require a special mode anyway to access, or use of the F- keys, etc.. They are arguably even more awkward in a GUI app where you need to take your hand off the keyboard and manipulate a mouse, and then there are the limitations to complexity mentioned in the last paragraph.1 vim's choice of a modal interface does not suffer from these problems. It also maximizes the usable screen area.

It could be observed that the editing aspect of many large, complex, graphical applications such as integrated development environments (IDEs) and word processors is deficient compared to vim because of the simple, non-modal, menu and ctrl driven interface. Considered this way, the reason vim uses modes is to make it a more powerful tool.

1. Although gvim does have drop down menus duplicating many common commands, they are clumsy compared to COMMAND mode; the only advantage to a menu system is that it is easy to learn. You don't have to remember much of anything, but it takes longer to do everything.

  • 6
    There were two legitimate directions to go when turning command-line editors into visual editors in the pre-mouse, pre-cursor-key, ASCII-keyboard-only days. One, used by VI, retains most of the "normal character" commands from the command line, but then requires that you switch into insert mode to type those same characters into the file. The other, used by Emacs, was to switch to using control keys and/or escape sequences to issue commands, eliminating the distinction between modes but requiring a different structure for the commands and interaction. Which is "better" is a religious debate.
    – keshlam
    Commented Jun 29, 2014 at 18:48

If it did not have a control mode and an insert mode it would not have been able to distinguish between the operations on a text and the text itself.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .