1

When I open a C file in vim, it seems to think I want 8 spaces worth of indentation, even though I specify my indentation preferences in .vimrc with the below:

set expandtab
set softtabstop=4
set shiftwidth=4
set autoindent

I also have:

filetype indent plugin on

The only fix I've come across so far is :set sw=4 in the buffer of the C file. I don't know why this works because I'm already setting that value in the .vimrc, so I can only guess that it's getting overwritten when the file-specific indentation settings are loaded. Unfortunately, deleting the filetype ... line from my .vimrc doesn't seem to help.

guntbert
  • 1,245
  • 1
  • 13
  • 27
  • 5
    You can check the current value and where they were last set with :verbose set ts sts sw (ts being the short name for tabstop, sts for softtabstop, and sw for shiftwidth). – Martin Tournoij Feb 21 '21 at 00:01
  • To me that looks like a duplicate of this question. There are a lot of chances that :verbose set shiftwidth will point a ftplugin that you'll want to override – statox Feb 22 '21 at 09:14

1 Answers1

0

Thanks for the comments letting me know about :verbose. It turns out there was another vim config file on the remote machine I'm using hidden in /etc/. Unfortunately it's read only, and it seems like it has priority when it comes to this line:

autocmd FileType c setlocal tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab