# Does a Vim submission have to end in a certain mode?

This question came up recently in a discussion of the validity of my answer to this question. It was argued that the answer was a V submission, not a Vim submission.

It is widely agreed that displaying text in Vim is a valid form of output. However, this brings up a question: Is a script/program still considered a valid Vim submission if it ends in Insert mode, or does it have to end in Normal mode?

# Yes, a Vim submission is valid if it ends in Insert mode.

Once the intended text has been outputted, the question has been answered. The insert mode is simply another command mode in which most keys are simply commands that output that character. For example, there are commands specific to Insert mode, as well as commands shared between Insert and Normal mode. Once the "commands" to output the text are executed, switching modes is unnecessary.

# Vim submissions can be valid in any mode if the output is displayed

In Aaron Miller's mentioned answer, the required output is shown in insert mode, and hence it is valid. However, if a change of mode/other motion is required for output, like in the V quine 2i2i, then it is required to be valid.

# No, a Vim submission is only valid if it ends in normal mode.

(borrowed from Aaron Miller)

Once the program has returned to normal mode, all pending operations are finished. A command was used to go into insert mode; the script can't be considered finished until that command is completed by the escape key.

I think it makes sense that the "end" of the program would be the state vim starts in.

• It should also be noted that although by default Vim starts in normal mode, that is not always the case. The evim command will start Vim in insert mode, and you must use <C-o> for any normal mode commands. You can also use the +startinsert cli argument to start in insert mode, or edit your .vimrc to start in insert mode by default. Apr 15 '21 at 16:53