Hacker News new | ask | show | jobs
by Rotundo 132 days ago
Sometimes something is a standard, not because it is the best, but because it is the thing that everybody expects and can trust to be there.

If you'd like to use another editor you can easily install it.

1 comments

Honestly I cannot imagine who expects the original vi and trusts vi to be there. Every Unix/Linux user I have met expects Vim and trusts Vim to be there. If there are users expecting original vi, they must be a very small minority.
A standards-conformant implementation of vi is absolutely required to be present and conformant to standards if the platform is certified by POSIX.2 (or whatever name the standard uses these days).

The latest standard for vi (and the rest of the utilities) can be found here:

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/

The standard for vi is specifically:

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/v...

Yes, Microsoft, this means you!

https://en.wikipedia.org/wiki/Microsoft_POSIX_subsystem

Microsoft's native UTF-16 really, really needs an editor that easily saves US7ASCII and UTF-8 correctly, both with LF and CR/LF. The native Windows tools are quite poor in getting this right.

> A standards-conformant implementation of vi is absolutely required to be present

No arguments there. This is all correct. The question is: Is Vim not standards-conformant?

If Vim isn't standards-conformant, I agree some people will expect the original vi to be present.

But if Vim is standards-conformant, do people still want vi to be present? Why?

> But if Vim is standards-conformant, do people still want vi to be present? Why?

It's much smaller and standards-compliant. IIRC, Debian started bundling nano instead of vim because nano is smaller (and easier to quit).

This has been addressed in a few realms, primarily shells.

One bash behavior oddity is that, when it is called as /bin/sh, this will work:

  $ cat pbasher
  #!/bin/sh
  alias p=printf
  p hello\ world!\\n

  $ ./pbasher
  hello world!
However, changing the shebang to #!/bin/bash results in this:

  $ ./pbasher
  ./pbasher: line 3: p: command not found
This is because an alias in a script is a POSIX.2 standard, but this historical bash did not allow this.

Forcing POSIX mode enables the alias:

  $ cat pbasher
  #!/bin/bash
  set -o posix
  alias p=printf
  p hello\ world!\\n

  $ ./pbasher
  hello world!
In the same way, platforms that care about POSIX.2 compatibility will adjust the behaviors to obtain certification, as bash has done. I saw HP-UX modify ksh88 into sh-posix, and vim also has a VIM_POSIX environment variable that enables a compliant standard mode.

There is discussion here:

https://vimhelp.org/vi_diff.txt.html

...the general GNU environment variable to trigger compliance used to be called POSIX_ME_HARDER.

And we all know ed is the standard Unix text editor. If you want vim you should be able to install it.