Some Tips on VIm and UNIX Shell

VIm (VI Improved)

VIm (VI Improved) is probably one of the most powerful text editors in UNIX. Its latest version is 7.1, and you can download it on its official web site. One of the powerful features is syntax highlighting, which can make VIm users be able to recognize some keywords of programming or scripting language by just seeing the different color on each keyword. Now, VIm has supported many popular programming and scripting language.

In my server, which is using FreeBSD 6.3 as the operating system, I have installed VIm-7.1 via port. Just do this following action:
  1. Go to port installation directory of VIm
    #cd /usr/ports/editors/vim
    
  2. Execute the port installation
    #make config install clean
    
  3. Wait until port installation is finished. It is not too long. Probably it will just take about 1 minute.
  4. After you have finished your installation, create a file .vimrc in your home directory For example, my username is knightdna and my home directory is in /home/knightdna, so I create .vimrc in that directory and write these on my .vimrc:
    syntax on
    set tabstop=4
    set showmatch
    
    The first line is used to enable the syntax highlighting feature of VIm, the second one is to set the count of the space in a tab key while using the editor, and the last is to show the command in VIm that probably match by just pressing the tab key. (e.g.: while writing :set n in command mode, if you press the tab key, VIm will automatically recognize your writing as :set number command).
  5. Then rehash your shell by do this following command:
    #rehash
    

Now you can use your fresh installed VIm with its one of powerful features, syntax highlighting.

UNIX Shell Configuration

There are few types of shell in UNIX (e.g.: bash, csh, and tcsh). I prefer using csh compared to the others since it has more support on programming and scripting (correct me if I'm wrong).

There is a file in your home directory which specifies the configuration of your shell. If you are using csh, then the file is .cshrc. If you are using bash, then the file is .shrc. We need to modify .cshrc file to enable color mode while using ls command, and the shell will also print your working directory.
  1. Go to your own home directory (e.g.: /home/knightdna)
    #cd /home/knightdna
    
  2. Open your .cshrc file with VIm (you may use the other editor)
    #vim .cshrc
    
  3. Add the alias of ls command with ls -FG. Write it on the line where the command aliases is declared. This is to enable color mode while you are using ls command
    alias ls ls -FG
    
  4. Change the value of your set prompt parameter. This is to print your current working directory while using your shell.
    set prompt = '\n[%B%m%b]%B%~%b%# '
    
  5. Save your .cshrc file and then quit from your VIm editor :wq
  6. Rehash your shell
    #rehash
    

Now you can use the ls command with color mode, and you'll notice the difference on your shell, right? That's all my simple tip for VIm and UNIX Shell Configuration. Hope this information is useful for you to make you more comfortable and enjoy your work with UNIX environment, especially when you are working in command line interface mode. Just correct me if I'm wrong. Thanks for viewing and have a good day!

-KnightDNA-
blog comments powered by Disqus