Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I wanted to have traditional indentation in vi / vim, I would enter these commands:

:set tabstop=4
:set shiftwidth=4
:set expandtab

It is tedious to type those commands every time I open a file. How do I permanently store those settings?

share|improve this question
up vote 9 down vote accepted

Create a file in your home directory called .vimrc, and put your commands in there:

set tabstop=4
set shiftwidth=4
set expandtab

Ubuntu's Vim Howto has a few pointers to basic customisation, if you want to dig deeper there's the Vim Book and the FAQ as well. also has a nice, big example of one person's .vimrc for you to rummage around in.

share|improve this answer


set tabstop=4
set shiftwidth=4
set expandtab


set ts=4 sw=4 
set expandtab

In your ~/.vimrc file. E.G. /home/user/.vimrc or /home/$(whoami)/.vimrc. You can use your other settings in .vimrc as well, the ones you regularly use, for example syntax on if you use the full version of VIM.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.