On 2011-04-11, Gerardo Marset wrote: > Consider the following pseudo-code: > > if file_is_code: > setlocal softtabstop=4 > setlocal shiftwidth=4 > setlocal expandtab > else: > setlocal softtabstop=8 > setlocal shiftwidth=8 > > Is there a simple way to do this?
You could put this in your ~/.vimrc: au BufWinEnter * if count(["c", "cpp", "python"], &ft) \| setlocal softtabstop=4 \| setlocal shiftwidth=4 \| setlocal expandtab \| else \| setlocal softtabstop=8 \| setlocal shiftwidth=8 \| endif That particular example is untested, but I have successfully used the elements before. The BufWinEnter event is one of the last events to be triggered after a new buffer is opened. The FileType event is not used because opening the buffer might not set the filetype. The count() function searches for the current filetype (&ft) in the given list of filetypes. Another approach would be something like this: set softtabstop=8 set shiftwidth=8 au FileType c,cpp,python \ setlocal softtabstop=4 \| setlocal shiftwidth=4 \| setlocal expandtab You could also write that autocommand like this: au FileType c,cpp,python setlocal softtabstop=4 shiftwidth=4 expandtab HTH, Gary -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php