2

I have read in various documentation that when Vim is started in Ex mode, it attempts to "act like" Ex, so I gather from this that Ex is a separate program and is not an actual part of the Vim source code and has its own separate code maintained by people other than those maintaining Vim. If this is true, what is the relationship between the two?

Does Vim copy and paste Ex's source code into its own project to create the Ex functionality, or does it try to emulate it from scratch?

I notice that the regular expression syntax and features in Ex and Vim appear to be identical. If they are completely separate programs, then how is the parity maintained? Do they have a shared regex library that both use?

2

ex is completely part of vim, it is just a special mode.

On Unix-systems there is a program called ex which is in fact a simple symlink to vim (just like gvim, evim, rvim, vimdiff et. al).

Vim acts on argv[0] (the invokation name) and switches mode accordingly.

  • Not sure this is a complete answer to the question (special mode, but what??)—however, a complete history of Ex might be too much. – D. Ben Knoble Jan 19 '18 at 15:59
  • vim has 7 basic + 7 additional modes. they are described in :help vim-modes – Naumann Jan 19 '18 at 17:59
  • This answers the fundamental question, ex is just symbolically linked to the vim executable which then examines its own startup command--that clears it up for me. – Tyler Durden Jan 20 '18 at 12:40
2

ex being part of vim is a modern contrivance, a convenience made possible by the particular way these text editors evolved. ex is actually a predecessor of vim/vi.

From Wikipeida:

The original Unix editor...was the rather user-unfriendly ed. G. Coulouris...developed an improved version called em in 1975. While visiting Berkeley, Coulouris presented his program to Bill Joy, who modified it...it became ex.

Since vim builds on ex and for the most part1 has a super-set of the functionality it is relatively easy to implement ex with vim.

ex was eventually given a full-screen visual interface...thereby becoming the vi text editor. In recent times, ex is implemented as a personality of the vi program; most variants of vi still have an "ex mode", which is invoked using the command ex, or from within vi for one command by typing the : (colon) character.

1I say "for the most part" because, again quoting Wikipedia, "although there is overlap between ex and vi functionality, some things can only be done with ex commands, so it remains useful when using vi."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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