2

I found project called The Traditional Vi, but I think that description, readme and manual don't provide exact information about compliancy with POSIX. I tried looking for other implementations that meet the requirements, but with no luck. I'm wondering, are there any POSIX compliant vi implementations? Thanks.

4
  • 3
    I mean, vim in compatible mode is mostly posix compliant (compliant enough to be the default vi for most distributions, anyway). Do you need precisely compliant or is this a curiosity?
    – D. Ben Knoble
    Feb 27 '20 at 1:10
  • @D.BenKnoble There's also a $VIM_POSIX environment variable and a handful of cpoptions for POSIX compliance. I just wrote an answer on using Vim in POSIX mode.
    – filbranden
    Feb 27 '20 at 2:54
  • 2
    Wikipedia page for vi also says: "Traditional Vi is a port of the original vi to modern Unix systems by Gunnar Ritter. Minor enhancements include 8-bit input, support for multi-byte character encodings like UTF-8, and features demanded by POSIX.2."
    – filbranden
    Feb 27 '20 at 3:03
  • @D.BenKnoble just curious.
    – James Kirk
    Feb 27 '20 at 23:52
3

There are a couple of vi clones besides the traditional ex-vi, that claim to be compatible to traditional vi. However I am not sure, if all meet complete POSIX specs and in the past, there were at least some contradictions between traditional vi and POSIX specs (think of multibyte text, regex flavors, undo and such).

You could have a look at busybox vi, neat-vi, nvi and nvi2. Most of those, at least extend the POSIX specs I believe.

For finding out, if they are compliant, I believe you will have to find out and compare against the POSIX specs. I believe there is also a POSIX test suite available, but not sure if it includes vi behaviour tests (and if so how comprehensive it is)

2
  • Regarding POSIX test suite, :help posix in Vim mentions it, together with notes such as "vi test 310 fails; exit code non-zero when any error occurred?" and "vi test 250 [...] will be changed in a new revision" (I guess specs have bugs too?) so yes looks like it does include vi behaviour tests.
    – filbranden
    Feb 27 '20 at 10:26
  • 1
    @filbranden yeah I remember having read something like this. However I couldn't find specific tests when googling around. Feb 27 '20 at 12:47
4

Vim has a special mode for POSIX compliance, which you can enable by setting the $VIM_POSIX environment variable to a non-empty value.

See :help posix, which explains it:

In 2005 the POSIX test suite was run to check the compatibility of Vim. Most of the test was executed properly. There are the few things where Vim is not POSIX compliant, even when run in Vi compatibility mode.

Set the $VIM_POSIX environment variable to have 'cpoptions' include the POSIX flags when Vim starts up. This makes Vim run as POSIX as it can. That's a bit different from being Vi compatible.

That section of the docs also goes into details of differences between Vim (even in Vi compatible mode) and POSIX, and why the differences exist.

See also the 'cpoptions' that are only enabled in POSIX mode. Vim option 'cpoptions' allows granular control of all compatibility settings.

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.