I have a problem with indentation using vim.
Lets say I have a file:
class My
end // <-- cursor is here
When I press O vim will create new line in between class and end and it will be indented. When I add a method def to it so the file looks like this:
class My
def my
end
end
Vim inserts tab for the automatic indentation not spaces so in git diff it looks like this:
class My
def my
def
end
My .vimrc is very basic:
set nocompatible
filetype off
let mapleader = "\<space>"
set tabstop=2 shiftwidth=2 expandtab " setting up tab behaviour
set number " show line numbers
set relativenumber " make the line numbers relative
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'thoughtbot/vim-rspec'
Plugin 'tpope/vim-surround'
Plugin 'vim-ruby/vim-ruby'
call vundle#end() " required
filetype plugin indent on " required
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
nmap 0 ^
nmap <leader>vr :tabe $MYVIMRC<cr>
nmap <leader>so :source $MYVIMRC<cr>
nmap <leader>cs :tabe db/schema.rb<cr>
imap jk <esc>
imap kj <esc>
syntax on
Any idea on how to fix this so the automatic indention is two spaces? It drives my nuts! I have to spend so much time fixing indentation after every commit....