I am using Vim 7.3.154 cli on Linux Mint 12 "Lisa"(x64).
I prefer using a tabstop
and shiftwidth
of 2 columns.
My .vimrc
has
:set ts=2
:set sw=2
to accomplish the same.
Whenever I open a new instance of Vim, tabstop
value is retained, so existing tabs are rendered according to .vimrc
. But somehow the shiftwidth
value gets changed to 3. This results in 3 column indention while auto-indenting.
Running :set sw=2
on the new instance of Vim fixes this issue.
Can anyone tell me why Vim is ignoring/changing shiftwidth
value from .vimrc
?
I tried disabling all plugins to no avail.
This answer just summarizes what we discussed in the comments. :)
This is most likely caused by the fact that you have file specific settings enabled. Check :h modeline
for more info on that. Make sure that those files you have the problems with don't have this line in them.
Instead of only setting tabstop
and shiftwidth
you should also setup a couple more settings regarding whitespace and tabs.
set noexpandtab " Make sure that every file uses real tabs, not spaces
set shiftround " Round indent to multiple of 'shiftwidth'
set smartindent " Do smart indenting when starting a new line
set autoindent " Copy indent from current line, over to the new line
" Set the tab width
let s:tabwidth=4
exec 'set tabstop=' .s:tabwidth
exec 'set shiftwidth=' .s:tabwidth
exec 'set softtabstop='.s:tabwidth
Check this video for some extra info: http://vimcasts.org/episodes/tabs-and-spaces/
So this is the answer to the actual problem that you were able to solve. That php.php
file was in the /plugin
directory. That directory gets loaded once, each and every time Vim starts up. Check this: http://learnvimscriptthehardway.stevelosh.com/chapters/42.html#vimplugin
If what you want is that file to load only on PHP files then you should put it in the /ftplugin
folder: http://learnvimscriptthehardway.stevelosh.com/chapters/42.html#vimftplugin
Read the documentation there, it should be a .vim
file, in other words in this case it would be called php.vim
.
What Pathogen or Vundle do is modify the runtimepath (:h runtimepath
), nothing more, nothing less.
So you can now accept this answer, by clicking the little green arrow to the left of this answer. :)