Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Install the nvi text editor on Panther UNIX
In Jaguar, the vi editor was nvi. For Panther, Apple replaced it with vim, which has different behaviour ("Vi improved" is a matter of opinion). Here's how I reinstalled nvi on my Mac, without removing vim. Note that I have tested this on only one Mac. I believe it will work on any other Panther box, but I have no proof of this. As with any installation, backup your files first and proceed with caution.

This is a long hint, but only because I've put in a lot of words to help people unfamiliar with installing software. I found the installation really quite easy and quick to do.

Download nvi (e.g., nvi-1.79.tar.gz) from a suitable web site. I used the Vi homepage/ (use the "Download the Vi editor" link at the bottom of the page). Uncompress it in the Terminal by typing:
 tar -xvzf nvi-1.79.tar.gz
This creates the directory nvi-1.79 (the numbers in the tar file and in the directory it creates will be different if you install a difference release of nvi). I recommend that you read the FAQ, LAYOUT, LICENSE, and README in that directory, and README in the build subdirectory.

When you are ready to install, go into the build subdirectory (all further commands will be run from here) and type:
 cd nvi-1.79/build
 ./configure
You will probably see a few messages and then this one:
checking host system type... configure: error: can not guess host type; you must specify one
This means that the configure script can't work out exactly what operating system you are running. To fix that, do these two commands:
 sudo cp /usr/share/automake-1.6/config.sub .
 sudo cp /usr/share/automake-1.6/config.guess .
Note the space and full stop at the end of the commands (for an explanation of what this does, see my reply dated May 8 '04 to this hint). NOTE: If you get a different error, then you should stop following these instructions and fix the error yourself. Sorry! Now run configure again:
 ./configure
This time, a lot of output lines should appear. If they all start with loading, checking, updating, and creating, all is well. If you get another error message, then you should stop following these instructions and fix the error. I didn't get any other errors. When configure has run successfully, enter this command:
 make
You will see a lot of code appearing in the output (e.g., cc -c -O -I. -I./../include -I./../regex). This is okay! You will probably also see some messages containing warning:... -- they are probably not anything you need to be concerned about (I did not have to do anything about them to get nvi to work for me). The last two lines of output from the make command will probably be:
 rm -f nex
 ln nvi nex
If you see an error message instead, then stop following these instructions and fix the error. When make has run successfully, enter this command (you must use sudo):
 sudo make install
You will probably see a few lines of code ending with these lines:

 [ -f VI.pm ] && /bin/cp VI.pm /usr/local/share/vi/perl && 
 cd /usr/local/share/vi/perl && /bin/chmod 444 VI.pm)
 /bin/sh: -c: line 1: syntax error near unexpected token `)'
 /bin/sh: -c: line 1: `[ -f VI.pm ] && /bin/cp VI.pm /usr/local/share/vi/perl &&  cd /usr/local/share/vi/perl && /bin/chmod 444 VI.pm)'
 make: *** [install_common] Error 2
This looks scary, but don't worry. However before proceeding further, make sure that your output DOES end with lines very similar to those -- if you have a different error message, stop and fix the error. The output lines above are saying that there's an unexpected bracket ')' in the file called Makefile. Even when I tried to fix that precise problem, I still got an error because the VI.pm file didn't exist. This is a Perl module and appears to NOT be necessary for nvi to work. I fixed this problem by CAREFULLY editing the file called Makefile:
  • Open Makefile in a text editor.
  • Search for the characters VI.pm. You will find these two lines:
     [ -f VI.pm ] && $(cp) VI.pm $(datadir)/vi/perl && 
     cd $(datadir)/vi/perl && $(chmod) $(fmode) VI.pm)
    
  • Comment out those lines by placing a # symbol in front of them:
     # [ -f VI.pm ] && $(cp) VI.pm $(datadir)/vi/perl && 
     # cd $(datadir)/vi/perl && $(chmod) $(fmode) VI.pm)
    
  • You should not change ANYTHING else in that file!
  • Save the file (overwriting the existing version).
Now run sudo make install again, as above. You will see several lines of code in the output (most lines starting with cd ). This is expected. If you see another error, stop following these instructions and fix it. That is the end of the installation process. You can now run nvi at any time by using this command:
/usr/local/bin/vi name_of_file_to_edit
At this stage, you can probably still run vim /path.... If you do NOT see that, then do NOT follow the rest of this hint unless you are sure you know what you are doing. Enter these two commands (you must use sudo):

 sudo rm /usr/bin/vi
 sudo ln -s /usr/local/bin/vi /usr/bin/vi
You can now use nvi by typing vi name_of_file_to_edit. You should still be able to use vim at any time with:
/usr/bin/vim  name_of_file_to_edit
[robg adds: I haven't tested this one. Another method for typing vi instead of nvi would be to just create an alias in your shell startup file -- this is probably safer. In tcsh, it'd be something like alias vi /usr/local/bin/vi.]
    •    
  • Currently 2.00 / 5
  You rated: 1 / 5 (4 votes cast)
 
[8,657 views]  

Install the nvi text editor on Panther | 4 comments | Create New Account
Click here to return to the 'Install the nvi text editor on Panther' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Uh, actually...
Authored by: CarlRJ on May 12, '04 04:28:16PM

I've used both nvi and vim (along with various earlier incarnations of vi) for a very long time, and I have to say, nvi is one I really try to avoid, because I've seen it corrupt data in a number of circumstances. In particular, filtering large blocks of text (e.g. "!Gsort") will sometimes mangle large sections of text (replacing them with nulls or garbage), and recovering files (e.g. "vi -r filename" after a network connection drop) often doesn't work (i.e. brings up an nvi session that core dumps the moment you try to do anything with it). So, use at your own risk.

Note that vim's behavior can be substantially modified by tweaking its configuration in ~/.vimrc to make it variously more, or less, like traditional vi (adding "set compatible" to one's ~/.vimrc will ensure you get the more traditional experience). As I said, though, I've been using various flavors of vi for a very long time, and vim is by far the best I've seen; I strongly encourage you to try exploring vim a little -- some of the changes take a little getting used to, but it really grows on you. I cringe a little when I have to use other versions of vi now.

Also, I would strongly suggest not removing files from the Apple-provided distribution (which a Software Update may fiddle with at any point), especially when all you want is to control which program gets run for a particular name. The historical Unix way of handling this is to ensure that /usr/local/bin appears earlier in your $PATH than /usr/bin, so your replacement version of vi in /usr/local/bin will be found before (in place of) the system's version in /usr/bin. The other common tactic is to symlink the preferred version into your personal bin directory (i.e. "ln -s /usr/local/bin/vi ~/bin/vi"), since ~/bin should always be near the front of your path.



[ Reply to This | # ]
Uh, actually...
Authored by: gruntfuggly on May 13, '04 04:43:28AM
The one thing I can't get vim to do which I would really like is for the insert mode to quit when I use an arrow key. I've got an environment variable (EXINIT) which contains a load of key mappings which work a treat with older versions of vi, but vim seems to ignore the 'escape' code in it. This is what it looks like:
setenv EXINIT 'map ^[Ox -| map! ^[Ox ^[-| map ^[Or +| map! ^[Or ^[+| map ^? X| map! ^[OD ^[h| map! ^[OC ^[ll| map! ^[OA ^[k| map! ^[OB ^[j| map! ^[[5~ ^B| map! ^[[6~ ^F| map! ^[OP ^[| map! ^[Oq ^[G| map! ^[[1~ ^[/| map ^[[5~ ^B| map ^[[6~ ^F| map ^[OP ^[| map ^[Oq G| map ^[[1~ /| map ^[Op i ^[| map! ^[[4~ ^[mz| map ^[[4~ mz| map! ^[[2~ ^["zP| map ^[[2~ "zP| map! ^[[3~ ^["zd`z| map ^[[3~ "zd`z| map! ^[Om ^["zy`z| map ^[Om "zy`z| set showmode| set shiftwidth=3| set ignorecase| set tabstop=8| set noslowopen| set report=1| set autoindent| set exrc'
Can anyone give me a way of making vim behave in the same way?

[ Reply to This | # ]
Re:Uh, actually...
Authored by: riceran on May 13, '04 12:11:49PM

That is precisely what the .vimrc, as mentioned above, is for. Just include your map commands in the vimrc, though your syntax will be a bit different than for your environment variable. I am pasting several of my mappings (just as they appear in my vimrc) below. It should be noted that <ESC> is actually what you type (literally) where you want an escape character. Same thing with <CR> for a carriage return. The syntax of <C-x>, where x may be replace with any letter, is what should be entered in order to obtain a control-ed character. There are similar <somethings> for the arrow keys and such.

map <C-S> :%s/\s\+/\t/g<CR>:%!align -s t<CR>

map <Leader>s <Esc>:!aspell -c --dont-backup "%"<CR>:e! "%"<CR><CR>

nmap <TAB> <C-W><C-W><C-W><C-_>



[ Reply to This | # ]
Install the nvi text editor on Panther
Authored by: resuna on Feb 19, '05 10:00:30AM
Some comments:
  1. You don't need to sudo those two copy commends, just use the "-f" flag on cp on the first one. You should try and avoid getting in the habit of using "sudo" to deal with this kind of thing.
    cp -f /usr/share/automake-1.6/config.sub .
    
  2. A better fix on the VI.pm problem is to put a "-" at the beginning of the first line, after you remove the extra ")"...
            -[ -f VI.pm ] && $(cp) VI.pm $(datadir)/vi/perl && \
                cd $(datadir)/vi/perl && $(chmod) $(fmode) VI.pm
    
  3. No, VIM is not a replacement for VI.


[ Reply to This | # ]