2

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.

5

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

set tabstop=2
  • 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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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