Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to change tab key spacing to 4 spaces in VIM editor on CVS server.

I know the :set tabstop=4 command is used for that but it does not have a permanent effect. After restarting VIM it changes to 8 spaces by default. I want to change it permanently.

Thanks in advance.

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

you just need to add it to your .vimrc file.

set tabstop=2
share|improve this answer
1  
where '.vimrc' file is located? –  Hit's Dec 12 '11 at 6:42
    
~/.vimrc in your home directory –  Nikhil Mulley Dec 12 '11 at 7:43
1  
You can use vim -u path_to_vimrc too if you want to have it elsewhere. By default, vim reads the file from your home directory. –  Luc M Dec 22 '11 at 18:56
add comment

Extend the answer:

  1. If you want to set it global, add set ts=2 to your ~/.vimrc - if it doesn't exist, just create new one.

  2. If you want to set tabstop for a specific file, use magic mode line in vim. Let's take C++ file as an example, add the line below in the beginning or the end of file: // vim: set ts=2

Read more about modeline in vim.

share|improve this answer
add comment

Your Answer

 
discard

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.