Skip to main content

Tips on Using VI Editor (continued)

· One min read

Some of the commands that you use for every session can be placed in a file named ".vimrc" in your home folder.

Personally, when editing code, I like to have my tabs to be of 4 characters wide. I also want the tab characters to be changed to 4 spaces. So in my .vimrc file, I place the following lines:

set smartindent set tabstop=4 set shiftwidth=4 set expandtab

I can then code and have the next line auto-indented. (There is another option called autoindent but it is not as good as smartindent.)

With the options set, the lines can also be indented in command mode or visual mode with the characters >> (shift dot key twice) and un-indented with << (shift comma key twice).