Guide On How To Install Vim On FreeBSD

Guide On How To Install Vim On FreeBSD 2017-08-04T09:52:42+02:00

A Step By Step Guide On How To Install Vim FreeBSD
Right before proceeding. I’m not going to take part in any “editor” wars here. People should use whatever they a comfortable with. For me that would be the VI editor. I have come used to this one and I rest assured to know it is available on every FreeBSD installation without the need of installing software first. That said some people may prefer Vim and hence this guide.

cd /usr/ports/editors/vim-lite && make install clean BATCH=yes

Setting Vim a the default editor. You have 2 options either create an alias in your shell’s profile file, or you can create a symlink that will launch Vim instead of VI.

Option 1: The alias approach insert the following line in your users shell profile somewhere.

cd /usr/ports/editors/vim-lite && make install clean BATCH=yes

Option 2: The symlink approach affects all users.

cd /usr/bin
mv vi vi.bak
ln -s /usr/local/bin/vim vi

Vim personal config file. You can copy the default vimrc configuration that is shipped with the installation like this.

cp /usr/local/share/vim/vim_version_number/vimrc_example.vim /home/username/.vimrc

Vim global config file. The location of the global configuration file may vary. You can check the location of the configuration file starting up Vim and type.


Once you have located the location either create a global configuration or copy the one that is shipped with the installation. The command below assumes the global configuration file to be located here /usr/local/etc/vim/vimrc

cp /usr/local/share/vim/vim_version_number/vimrc_example.vim /usr/local/etc/vim/vimrc

Vim and backup files. Vim has a habit of saving a backup of the file you are working on and append a ~ as suffix indicating it’s a backup.

Now this may cause some cluttering once you have a gazillion ~ files in a directory. Sure you could just run a script to delete them (would work) or disable Vim backups all together (Now that would be a bit over the edge). I recommend just having a backup directory for these files so they don’t clutter and you have the best of both worlds.

Here is how that works. Create a directory for your backup files and in your vimrc configuration file add the following 3 lines. Be sure to remove or comment out existing backup settings in your .vimrc file.

set backupdir=~/.vimtmp,.
set directory=~/.vimtmp,.
set backup

Please note. You will have to manually create whatever directory you want to store your Vim backup files in. Vim will not create them for you. Also the syntax has a comma i.e , after it this only means that is the directory does not exists it will use ~/. as directory instead which is handy if you forgot to add the directory.

Vim and undo files. Following the same rules as above we can adjust where Vim is storing it’s undo files as well like this.

set undodir=~/.vimtmp,.
set undofile

And we are done here.

Spell checkers don’t – Grammar checkers don’t either.