I've been an AIX administrator for many years now, and I've always been a fan of the vi editor. But after working on a few linux projects there is one thing I think is missing from a standard AIX install and that is the VIM editor. One of my favorite features of the VIM editor is by far the syntax highlighter. What an improvement over reading/editing black and white code. Fortunately, IBM distributes a compiled version of VIM (v 6.3) in their AIX Toolbox for Linux Applications.
So to get started, you'll need to either load up your AIX Toolbox CD/DVD or download the VIM rpm packages from the link above. I prefer to download from the link above, as you're sure to get the latest and greatest. The three packages you'll need are:
vim-minimal-6.3
vim-enhanced-6.3
vim-common-6.3
Once you have those three packages, send them over to your AIX lpar, and place them in their own directory (ex. /usr/src/rpms , /usr/local/src/rpms , etc). The next few steps will require root access, so if you're not the admin, you may have to plead, beg, fill out a TPS report, or buy em a coffee for their help.
Step 1 - Installation
As root, cd into the directory where you placed the vim-*.rpm packages and run:
rpm -i vim*
You should now have the vim editor installed on your system. To see if it was installed correctly, you can run:
#which vim
/usr/bin/vim
You should see /usr/bin/vim return. If not, check the install or your $PATH variable.
Now comes the fun part.
Step 2 - Configuration
The configuration files for the VIM editor are installed by default to /usr/share/vim/vim63, and the configuration file you need to add/modify will be at /usr/share/vim/vim63/macros/vimrc. This file will set the default behavior for the VIM editor for all accounts on this machine. Now you'll probably notice there isn't a file called vimrc in this directory, but there is a example file in the parent(/usr/share/vim/vim63/vimrc_example.vim). Copy this file to the VIM default location:
cp /usr/share/vim/vim63/vimrc_example.vim /usr/share/vim/vim63/macros/vimrc
Once the file has been copied over, you'll need to append the following code to the end of the vimrc file:
if &term =~ "xterm"
if has( "terminfo" )
set t_Co=8
set t_Sf=^[[3%p1%dm
set t_Sb=^[[4%p1%dm
syntax on
else
set t_Co=8
set t_Sf=^[[3%dm
set t_Sb=^[[4%dm
endif endif |
So now you should have a functional VIM editor with syntax highlighting set as the default config. Try editing a script by calling "vim" instead of "vi"."Hold ctrl" v [ "Release ctrl"
Step 3 - Replace vi with VIM
By now you should hopefully have a working vim editor, but don't you want to share the awesomeness with the rest of the users? What we'll need to do is create an alias so when users call vi, they're acutally calling vim. In my case, we use the ksh (korn shell) as the default shell for all accounts, so we can modify the /etc/profile to "hook-up" all the users. Append this line to your /etc/profile (in bash I think you can append this to /etc/bashrc):
Step 4 - Enjoyalias vi=/usr/bin/vim
Try doing this on a Sunday night of Monday morning, so when all your developers come in on Monday they have something to brighten up their week.