Wczoraj zainstalowałem vundle, a ponieważ to zrobiłem, szerokość tabulacji, którą skonfigurowałem w moim vimrc, jest ignorowana i ustawiana z powrotem na 4 zamiast 2.
Dowiedziałem się, że przyczyną tego jest następujący wiersz po akapicie pełnym:
filetype plugin indent on
Moje wcięcie jest ustawione w ten sposób:
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=2
exec 'set tabstop=' .s:tabwidth
exec 'set shiftwidth=' .s:tabwidth
exec 'set softtabstop='.s:tabwidth
Możesz sprawdzić mój pełny vimrc tutaj .
Testowałem problem wcięcia za pomocą skryptu python (gdzie wcięcie naprawdę ma znaczenie).
Próbowałem już zmienia filetype plugin indent onsię filetype plugin on, ale to niczego nie zmienia. Tylko komentowanie tej linii pomaga.
Teraz przewodnik instalacji Vundle mówi, że ta linia jest wymagana.
Jak rozwiązać ten problem z wcięciem? Czy mogę po prostu pominąć linię typu pliku, czy też naprawdę jest to konieczne, aby zachować ją w vimrc?
Rozwiązanie:
Dzięki @ChristianBrabandt i @romainl znalazłem rozwiązanie, które może również znajdować się w jednym pliku vimrc:
filetype plugin indent on
[...]
set noexpandtab " Make sure that every file uses real tabs, not spaces
set shiftround " Round indent to multiple of 'shiftwidth'
set autoindent " Copy indent from current line, over to the new line
" Set the tab width
let s:tabwidth=2
au Filetype * let &l:tabstop = s:tabwidth
au Filetype * let &l:shiftwidth = s:tabwidth
au Filetype * let &l:softtabstop = s:tabwidth