Unix/Linux

Global Syntax Highlighting with VIM on AIX

steloflute 2012. 6. 8. 11:33

http://drupal7.notanothersheep.com/?q=node/29

 


사실 vim-minimal-6.3 은 설치할 필요 없다.


Global Syntax Highlighting with VIM on AIX

parker's picture

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
Important: In order to create the ^[ you'll need to manually do the following:

"Hold ctrl" v [ "Release ctrl"

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".

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):

alias vi=/usr/bin/vim

Step 4 - Enjoy

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.


'Unix/Linux' 카테고리의 다른 글

(AIX) list and remove at jobs  (0) 2012.06.15
Installing vim on aix  (0) 2012.06.08
ksh color prompt  (0) 2012.06.05
Disable screensaver on Ubuntu Server  (0) 2012.05.28
How do I permanently disable Linux's console screen saver, system-wide?  (0) 2012.05.28