Setting up vi
Sunday, September 28th, 2008As I return to programming in Linux again I have begun to regain my previously acquired tools and knowledge. Because of this, I have decided to write this post describing how to setup a basic configuration file for the vi editor. This file will prevent the headaches of having to reset all of your settings every time you load a vi session.
Make a new file in your home directory called .exrc. What will I use to edit this file…vi of course!
% cd /home/craig
% vi .exrc
Inside the file is where you write all of your set commands that you would normally write at the start of a vi session.
The following are settings that I find I use often.
# number - Displays line numbers
# autoindent - Indents the left margin of new lines by the indent of the previous line
# tabstop - Sets the number of spaces for each tab on the screen.
# wrapmargin - Starts a new line before reaching the right margin. This occurs when the last word is less then the set number of characters./
My configuration file looks like the following.
:set wrapmargin=15
:set number
:set autoindent
:set tabstop=5
Save and restart vi, your changes should now be visible in your editor. Enjoy.