As a solution to the problem described in the question Why does vim not obey my expandtab in python files?, I have added this to my vimrc:
let g:use_tabs = 1
let g:indent_width = 4
let g:tab_width = 4
function! SetIndent()
if g:use_tabs
set noexpandtab
set softtabstop=0
let &shiftwidth = g:indent_width
let &tabstop = g:tab_width
else
set expandtab
let &softtabstop = g:indent_width
let &shiftwidth = g:indent_width
let &tabstop = g:tab_width
endif
endfunction
autocmd VimEnter * call SetIndent()
This works perfectly when running vim in a terminal, but it seems like MacVim doesn't run the call SetIndent()
command at all.
Is this because MacVim ignores VimEnter
or runs it at another time than vim?
How would I fix my vimrc so it also work in MacVim?
Edit: Link to my full vimrc: https://ghostbin.com/paste/3xnw7