Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim keeps changing expandtab

Tags:

vim

Sometimes Vim keeps changing my expandtab settings. I want spaces always for specific file types but sometimes, when I insert a new line, it gives me a tab instead.

verb set expandtab?

Tells me nonexpandtab was set in this file:

set autoindent
set expandtab
set shiftwidth=4
set numberwidth=4
set softtabstop=4
set smartindent
autocmd FileType ruby,php,vim,jade,erb,css,scss,html,coffee,javascript setlocal expandtab sw=2 sts=2
au FileType xml exe ":silent 1,$!XMLLINT_INDENT='    ' xmllint --format --recover - 2>/dev/null"
set backspace=indent,eol,start

" Command to set how many spaces
command! -nargs=1 SetSpace call s:SetSpace(<f-args>)
function! s:SetSpace(space)
  setlocal expandtab sta
  let &sw = a:space
  let &sts = a:space
endfunction

Where exactly did it set noexpandtab ?

Update
I notice that this problem happens when I enter a new line and if the line happens to be indented as 8 spaces then Vim converts to a tab. How to fix this?

like image 888
BPm Avatar asked Jul 23 '14 22:07

BPm


1 Answers

The :verbose set unfortunately doesn't capture all instances, so it may give no or a wrong answer.

Alternatively, you can capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine the vimlog log file for suspect commands.

like image 117
Ingo Karkat Avatar answered Nov 01 '22 13:11

Ingo Karkat