Contact us

OpenBSD Color Vi/VIM Editor

Before when I think on exploring a new Operating System there are two choices that was in front of me these are OpenBSD and FreeBSD.

At that time I did not think about which Operating System is the most secure and the fastest. All that was on my mind is which Operating System is closer to Linux when it comes to Systems Administration and ease of use.

One that hinders me is the text editor and the tab completion when it comes to BSD variants. My requirements for the editor are: first it must feel like Linux and must have a tab completion and color code (syntax highlighting) the listed items.

I did my research and settled to OpenBSD with colored support to CLI and Vi/VIM text editor. When the installation is complete the behavior of vi/vim is almost thesame as Linux vi/vim which have color or syntax highlighting support.

Install OpenBSD Vi/Vim Color packages

Setup the repository

Note: Mirror lists for openbsd and other packages

http://www.openbsd.org/ftp.html

[mylogin@hostname folder]# export PKG_PATH=ftp://ftp.jp.openbsd.org/pub/OpenBSD/<version>/packages/i386/

Installing color vi/vim text editor package

[mylogin@hostname vi]# pkg_add vim-<version>-no_x11.tgz

Install gnuls package. This will allow color coding to ls commands in OpenBSD

[mylogin@hostname folder]# pkg_add gnuls

We need to install bash shell as I am comfortable to bash.

[mylogin@hostname vi]# pkg_add bash

OpenBSD Color Vi/Vim Configuration

Add color to vi/vim (syntax highlighting) text editor when editing configurations or other files.

Change shell defaults. In the example we change root’s shell

[mylogin@hostname vi]# cd

[mylogin@hostname vi]# user mod -s /usr/local/bin/bash root

[mylogin@hostname vi]# cp /etc/X11/app-defaults/XTerm-color .

[mylogin@hostname vi]# mv XTerm-color .Xdefaults

Edit .bash_profile. This will allow the configurations to be loaded when a user is login.

[mylogin@hostname vi]# nano .bash_profile

Append the following lines to .bash_profile

PS1='[\u@\h:\w] # '
alias ls='gls --color=always'
alias ll='gls -lah --color=always'
alias vi='vim'
alias rm='rm -iP'
alias useradd='adduser'
alias poweroff='shutdown -r now'
alias lsof='/usr/local/sbin/lsof'
export TERM=xterm-color
# TERM=color_xterm
export http_proxy='http://<proxy_server>'
export PKG_PATH='ftp://ftp.jp.openbsd.org/pub/OpenBSD/<version>/packages/i386/'
export FETCH_PACKAGES=yes

Edit vimrc to have the following entries

[mylogin@hostname vi]# nano .vimrc

set background=dark
syntax on
set hlsearch
set nocompatible
set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set showmatch
set ruler
set incsearch

After editing, user must logout then login again for the changes to take effect. Do some testing and se if vim editor and ls already have color coded in it. Isn't OpenBSD Color Vi/Vim same almost thesame as Linux Color Vi/Vim?

Thats it! you may learn more regarding in using Vi/VIM here.

Tell a friend


This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
Bookmark and Share RSS News Feed