(这可能比SO问题更具超级用户问题,但我认为它对Stata用户来说非常本地化。)
我新安装了Vim,但现在我已经失去了与Stata的智能缩进。即使我有filetype indent on
,我也能获得开箱即用的语法高亮,但不能缩进。是否需要为Stata添加额外的缩进文件?我在note on text editors中没有看到这一点。
我尝试set smartindent
,但这也不起作用(似乎Vim wiki on source code indenting推荐smartindent
。
有什么想法吗?我将粘贴我的_vimrc(我在Windows 8.1上使用Vim 7.4),但我不确定我是否有_vimrc问题(R和LaTeX工作得很好),但是/ vimfiles问题。
" ----------------------------------------
" from sachet http://yoursachet.com/
" ----------------------------------------
set nocompatible
" Pathogen
call pathogen#infect()
call pathogen#helptags()
set background=dark
colorscheme solarized
" ----------------------------------------
" from my original _vimrc
" ----------------------------------------
set expandtab
set shiftwidth=4
set softtabstop=4
set textwidth=78
set visualbell
set guifont=Source\ Code\ Pro:h11
" vim-pandoc
" ----------------------------------------
" location of .bib files
let g:pandoc_bibfiles=['C:\Users\richa_000\texmf\bibtex\bib\library.bib']
" vim-R-plugin
" ----------------------------------------
" minimum requirements
set nocompatible
syntax enable
filetype plugin on
filetype indent on
" Vim LaTeX Suite
" ----------------------------------------
" http://vim-latex.sourceforge.net/documentation/latex-suite.html
" minimum requirements for vimlatexsuite
" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
"filetype plugin on " redundant with vim-R-plugin settings
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: This enables automatic indentation as you type.
"filetype indent on " redundant with vim-R-plugin settings
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
" " this is mostly a matter of taste. but LaTeX looks good with just a bit
" " of indentation.
" set sw=2
" TIP: if you write your \label's as \label{fig:something}, then if you
" type in \ref{fig: and press <C-n> you will automatically cycle through
" all the figure labels. Very useful!
set iskeyword+=:
" Fix double brackets problem
" http://tex.stackexchange.com/questions/105758/vim-latex-adds-extra-brackets-when-typing-empty-brackets
set backspace+=start
" For cite completion
let g:Tex_BIBINPUTS='C:/Users/richa_000/texmf/bibtex/bib/library.bib'
" compile pdfs from dvi
let g:Tex_FormatDependency_pdf='dvi,ps,pdf'
let g:Tex_CompileRule_pdf='ps2pdf $*.ps'
let g:Tex_DefaultTargetFormat='pdf'
" pdf viewer
let g:Tex_ViewRule_pdf='C:/Program Files (x86)/SumatraPDF/SumatraPDF'
" Stata http://fmwww.bc.edu/repec/bocode/t/textEditors.html#vim
" -------------------------------------------------------
" STATA DO-FILE SCRIPTS
fun! RunIt()
w
" *** CHANGE PATH AND NAME TO REFLECT YOUR SETUP ***
!start "C:\ado\personal\rundo.exe" "%:p"
endfun
:map <F8> :<C-U>call RunIt()
:imap <F8> <Esc>:<C-U>call RunIt()
fun! RunDoLines()
let selectedLines = getbufline('%', line("'<"), line("'>"))
if col("'>") < strlen(getline(line("'>")))
let selectedLines[-1] = strpart(selectedLines[-1], 0, col("'>"))
endif
if col("'<") != 1
let selectedLines[0] = strpart(selectedLines[0], col("'<")-1)
endif
let temp = tempname() . ".do"
call writefile(selectedLines, temp)
" *** CHANGE PATH AND NAME TO REFLECT YOUR SETUP. USE \\ INSTEAD OF \ ***
exec "!start C:\\ado\\personal\\rundo.exe " . temp
" Delete the temp file after Vim closes
au VimLeave * exe "!del -y" temp
endfun
:map <F9> :<C-U>call RunDoLines()
:imap <F9> <Esc>:<C-U>call RunDoLines()
" Lines added by the Vim-R-plugin command :RpluginConfig (2014-Jan-27 09:42):
syntax on
答案 0 :(得分:1)
你有没有尝试谷歌搜索&#34; vim indent stata&#34;?我在结果的第一页上找到了这篇博文:http://tcry.blogspot.com/2010/04/stata-indenting-in-vim.html。它建议
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=
您可以将这些行添加到vimrc文件中。这将设置这些选项的全局值,如果没有其他任何内容更改全局值,那么在编辑Stata文件时应该获取这些值。或者您可以使用这些行添加缩进文件:将所有set
命令更改为setl
,以便它们不会影响全局值。要遵循标准,请在顶部添加这些行(来自同一篇博文):
" Only load this indent file when no other was loaded yet.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
在评论中,你问,
...不是首选
'cindent'
或'smartindent'
的文件类型缩进?
&#34;文件类型缩进&#34;只是意味着:source
indent/<filetype>.vim
下的文件indent/stata.vim
(在这种情况下,~/.vim/
)'runtimepath'
(或'indentexpr'
指定的其他目录)。该文件可以设置任何合适的选项:'cindent'
是最灵活的,但如果{{1}}和相关选项足够好,您也可以使用它们。