Vim's documentation has this to say about the :open command:

This command is in Vi, but Vim only simulates it:

                                                        *:o* *:op* *:open*
:[range]o[pen]                      Works like |:visual|: end Ex mode.
                                {Vi: start editing in open mode}

:[range]o[pen] /pattern/    As above, additionally move the cursor to the
                                column where "pattern" matches in the cursor

Vim does not support open mode, since it's not really useful.  For those
situations where ":open" would start open mode Vim will leave Ex mode, which
allows executing the same commands, but updates the whole screen instead of
only one line.

It does not comment on the nature of the "simulation", and why this is considered to be a simulation rather than a real command with different behavior. When run from ex mode (Q), it does indeed behave as described.

However, there also appears to be a different open command. When run from the normal command line, or from ex mode with different arguments, it appears to be a synonym for :edit. When run from command mode with a /pattern/, it positions the cursor and apparently runs :edit (with the cursor position only being evident if :edit fails.) It can also be run as :open /pattern/ file, which positions the cursor and runs :edit file

My question is: Why is this not documented? Are there any differences from :edit that I am not noticing? Was :open once a synonym for :edit and only changed later in an attempt to halfway comply with POSIX?

2 Answers 2


The "open mode" of vi was useful for terminals that had a single line, such as hardcopy terminals. In open mode, vi had a "single line view" of the file. Moving the cursor around would redraw the entire line, and deleted characters printed differently.

The "simulation" that vim does is simply supporting the command, making it act (as the documentation says) like :visual and since :visual is "otherwise the same as :edit," that's probably why you see it acting like :edit.

From a source code perspective, :open is implemented in ex_docmd.c (ex_open()). It does some stuff to deal with the case where it is provided a regular expression, but always ends with a call to do_exedit().

The implementation of :edit, :badd and :visual is contained in the ex_edit() function in the same file, and that function is a direct call to do_exedit() (nothing else). Thus, other than when handling the regular expression parameter, the same code gets called. do_exedit() is a bit hairy, and it's behavior is modified heavily based on the actual command that was issued, but it never explicitly checks for the command tokens for open/edit/visual. Thus, the three commands result in more-or-less the same code getting run in do_exedit().


From An Introduction to Display Editing with Vi:

If you are on a hardcopy terminal or a terminal which does not have a cursor which can move off the bottom line, you can still use the command set of vi, but in a different mode. When you give a vi command, the editor will tell you that it is using open mode. This name comes from the open command in ex, which is used to get into the same mode.

The only difference between visual mode and open mode is the way in which the text is displayed.

In open mode the editor uses a single line window into the file, and moving backward and forward in the file causes new lines to be displayed, always below the current line. Two commands of vi work differently in open: z and ^R. The z command does not take parameters, but rather draws a window of context around the current line and then returns you to the current line.

If you are on a hardcopy terminal, the ^R command will retype the current line. On such terminals, the editor normally uses two lines to represent the current line. The first line is a copy of the line as you started to edit it, and you work on the line below this line. When you delete characters, the editor types a number of \'s to show you the characters which are deleted. The editor also reprints the current line soon after such changes so that you can see what the line looks like again.

It is sometimes useful to use this mode on very slow terminals which can support vi in the full screen mode. You can do this by entering ex and using an open command.

:open is an artifact of Vim's origin as a Vi clone that is completely useless today. I can only assume that it remains there for POSIX compatibility.

Despite vague similarities, :open is not an alternative to :edit by any stretch of the imagination.

  • That's a really horrible thing to have to discover. Thanks for making it a little easier to find. Commented Feb 10, 2023 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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