Vim on FreeBSD
Posted Feb 15th, 2015
Vim takes a little bit of tweaking to get it running perfectly. These quick instructions will get you started.
Assuming your ports tree is up to date (if not, update using these instructions).
Note that we install the vim-lite port, which installs a default .vimrc file for us suitable for terminal use. If you're installing Vim in an X11 environment or need some additional options, you can install the standard Vim port and browse the included example configuration files afterwards.
# cd /usr/ports/editors/vim-lite # make config && make config-recursive # make && make install
Next, if you haven't done so already, you'll need to tweak your environment to correctly handle some control keys. This info is from this excellent page.
While we're here, you may as well change the default editor from ee to vim:
setenv EDITOR vim
Add the following to the bottom of the file:
if ($term == "xterm" || $term == "vt100" \ || $term == "vt102" || $term !~ "con*") then # bind keypad keys for console, vt100, vt102, xterm bindkey "\e[1~" beginning-of-line # Home bindkey "\e[7~" beginning-of-line # Home rxvt bindkey "\e[2~" overwrite-mode # Ins bindkey "\e[3~" delete-char # Delete bindkey "\e[4~" end-of-line # End bindkey "\e[8~" end-of-line # End rxvt endif
Finally, source the file to make the changes take effect immediately.
The vim-lite port installs a default .vimrc file for you; however, if you installed the standard package or need to restore the default, run this:
cp `find /usr/local/share/vim/ -type f -name vimrc_example.vim` ~/.vimrc
That's it, you're done. You'll probably want to tweak your ~/.vimrc file to your liking, but the defaults work pretty well.
Enjoy the wonderful world of Vim!