为何要将vi自身作为参数传递给vi?解析/bin/vi vi与/bin/vi的差异
vi as an Argument to /bin/vi? Great question—let’s unpack what’s happening here, since it ties directly into how Vim (the tool usually behind your system’s vi command) behaves based on how you launch it.
First, quick context: On most modern Linux systems, /bin/vi is either a symbolic link to Vim or an alias that runs Vim. So when you execute /bin/vi, you’re actually running Vim, but it might tweak its behavior to mimic classic vi if it detects it was called under the vi name.
Now let’s break down the two scenarios:
1. Running /bin/vi without arguments
When you launch Vim without specifying a file, it starts in its default interactive mode: it shows its welcome screen (with version info, shortcut hints, etc.), drops you into an empty buffer, and loads any user configurations you’ve set up. Even though it’s called as vi, it’s still Vim under the hood—so you see that familiar Vim interface.
2. Running /bin/vi vi
When you pass vi as an argument, you’re explicitly telling the editor: "Open the file named vi in the current directory." Here’s what plays out:
- If a file named
vialready exists in your folder, Vim opens that file directly—no welcome screen, just the file’s content ready to edit. - If no such file exists, Vim prepares to create a new file named
viand drops you straight into edit mode for it, again skipping the welcome screen.
That’s the core difference: specifying a target file (even a non-existent one) skips Vim’s default startup welcome flow. It doesn’t mean "Vim isn’t opening"—it’s still Vim running, just in a focused file-editing state instead of the default empty buffer with a welcome screen.
One extra note: If you wanted to force Vim to run in strict classic vi compatibility mode, you could use vim -v or set the nocompatible option—but that’s a separate behavior from what you’re observing here.
内容的提问来源于stack exchange,提问作者ng.newbie

