vim settings: tabs, spaces, indents

Basics

tabstop – amount to indent when using <Tab>

shiftwidth – amount to indent when using ‘>’ or ‘<‘

expandtab – always insert spaces at the amount of tabstop

set tabstop=4 set shiftwidth=4 set expandtab

 

How to change tab size based on filetype

setting it inline

make sure there are no spaces between the languages

autocmd FileType javascript,haskell set tabstop=2 shiftwidth=2

setting it with a function

autocmd FileType javascript, haskell call s:set_indents_at_2()

function! s:set_indents_at_2()
  set tabstop=2
  set shiftwidth=2
endfunction

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s