FreeBSD install VIM text editor

by on May 9, 2007 · 2 comments· last updated at July 8, 2008

Q. Quick question – How do I install VIM text editor for my FreeBSD server? Currently it has old version of vi. I like vim as it is a highly configurable text editor and efficient one.

A. VIM (Vi IMproved ) is not installed by default under FreeBSD. Vim is a text editor that is upwards compatible to Vi. It can be used to edit all kinds of plain text. It is especially useful for editing programs. You can install vim binary package or use FreeBSD's ports system.

Task: Install vim binary package

Type the following command to install vim lite version:
# pkg_add -r -v vim-lite

You can also use FreeBSD ports system to install vim:
# cd /usr/ports/editors/vim-lite/
# make install clean

To start vim type command:
$ vim

You can also create a alias using alias command:
$ alias vi='vim'

Add above alias to your shell start up file such as ~/.bashrc / ~/.cshrc

Task: Setup global vimrc file

You need to copy default vimrc file from /usr/local/share/vim/vim71/vimrc_example.vim to /usr/local/share/vim:
# cp /usr/local/share/vim/vim71/vimrc_example.vim /usr/local/share/vimrc

Task: Personal ~/.vimrc file

You can customize ~/.vimrc as per your requirements. Here is my own file:
$ cat ~/.vimrc
Sample output:

set nocompatible " must be the first line
filetype on
filetype indent on
filetype plugin on
set laststatus=2
set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P


You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 2 comments… read them below or add one }

1 shake January 31, 2010 at 8:39 pm

create a softlink between vim and vi would easy.

# whereis vim
vim: /usr/local/bin/vim /usr/local/man/man1/vim.1.gz /usr/ports/editors/vim
# whereis vi
vi: /usr/bin/vi /usr/share/man/man1/vi.1.gz
# mv /usr/bin/vi /usr/bin/vi.bak
# ln -s /usr/local/bin/vim /usr/bin/vi

Reply

2 zeromind April 12, 2010 at 4:35 pm

In ‘Task: Setup global vimrc file’ it should be
# cp /usr/local/share/vim/vim71/vimrc_example.vim /usr/local/share/vim/vimrc
instead of
# cp /usr/local/share/vim/vim71/vimrc_example.vim /usr/local/share/vimrc

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: