Did you try Googling for "vim indent stata"? I find this blog post on the first page of results: http://tcry.blogspot.com/2010/04/stata-indenting-in-vim.html . It recommends
set cindent
set shiftwidth=5
set cinoptions=>s,e0,n0,f0,{0,}0,^0,:0,=0,l0,b0,g0,h0,p0,t0,i0,+0,c0,C0,/0, (0,u0,U0,w0,W0,m0,j0,)20,*30,#0
set cinwords=
You could add those lines to your vimrc file. That will set global values of these options, and if nothing else changes the global values, then you should get these values when editing Stata files. Or you could add an indent file with those lines: change all the set
commands to setl
so that they do not affect the global values. To follow standards, add these lines at the top (from the same blog post):
" Only load this indent file when no other was loaded yet.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
In the comments, you ask,
... isn't file type indentation preferred to
'cindent'
or'smartindent'
?
"File type indentation" just means :source
ing a file at indent/<filetype>.vim
(in this case, indent/stata.vim
) under ~/.vim/
(or some other directory specified by 'runtimepath'
). That file can set whatever options seem appropriate: 'indentexpr'
is the most flexible, but if 'cindent'
and related options are good enough, you may as well use them.