I just installed version 8 of Vim and notice in the bin directory of the install location that all the above mentioned programs point to the same binary – vim. Then, how does it know when I invoke ex to open in the ex mode and so on?

1 Answer 1


Inside vim's source code, there is a main function roughly like

int main(int argc, char **argv) {
    if (!strcmp(argv[0], "ex"))


    return 0;

This function is where the operating system starts the execution of the vim executable. The naming and arguments differ between operating systems, but we'll assume -nix style. By convention, the shell passes words from the command line you typed as strings in the argv array when starting the program. E.g.,

ex filename

becomes char *argv[] = {"ex", "filename"};

Similarly for view, vimdiff, etc.

  • 5
    You can try this yourself at home. Create a script: echo $0, add a symlink to it, and run the symlink. Jun 1, 2020 at 16:35

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.