indentation - Autoindenting not working in vim? -


i using vim , wish autoindent every time need (such after brace in javascript or after colon in python). reason, tried autoindent , smartindent, every new line gave me 2 tabs instead of one. why doing this? thought insert 1 tab.

my current ~/.vimrc file has:

    set ts=4     set autoindent     set smartindent     filetype plugin indent on 

you need set well:

:set shiftwidth=4 softtabstop=4 

tabstop number of columns real "\t" tab takes:

:he shiftwidth      number of spaces use each step of (auto)indent.  used     |'cindent'|, |>>|, |<<|, etc.     when 0 'ts' value used.  :he softtabstop      number of spaces <tab> counts while performing editing     operations, inserting <tab> or using <bs>.  "feels"     <tab>s being inserted, while in fact mix of spaces , <tab>s     used. 

whereas tabstop:

 :he tabstop      number of spaces <tab> in file counts for.  see     |:retab| command, , 'softtabstop' option. 

as bonus, here's few mappings i've set that, when need work on projects not use favorite default of expand tabs 4 spaces indent:

nmap <leader>t2 :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<cr> nmap <leader>t4 :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<cr> nmap <leader>t8 :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<cr> nmap <leader>t2 :set noexpandtab tabstop=2 softtabstop=2 shiftwidth=2<cr> nmap <leader>t4 :set noexpandtab tabstop=4 softtabstop=4 shiftwidth=4<cr> nmap <leader>t8 :set noexpandtab tabstop=8 softtabstop=8 shiftwidth=8<cr> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -