打开一行('o')自动缩进 - 如何在.txt文件中避免?

时间:2012-08-03 08:01:20

标签: vim

每当我想在Vim中用 o 打开一个新行时,它会自动缩进(而不是从行的开头开始)。这是为什么?我怎样才能解决这个问题? (我不想关闭自动缩进,这对其他文件类型很有用。)

更新:

它似乎与实际文本有关:自动缩进(=)以下两行缩进第二行(为什么? - 我希望两行在第1列开始!)

*in golf: failing to make par is a loss, missing a birdie putt is a foregone gain, not a loss
*negotiations, especially renegotiations: concessions you make cause you much more pain      

更新2(我的.vimrc):

:set cpoptions+=$
:set virtualedit=all
:filetype plugin indent on
:set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
:set fdm=expr
:set gfn=Ubuntu\ Mono\ 11
setlocal autoindent
setlocal cindent
setlocal cinwords=if,else,elseif,do,while,foreach,for,case,default,function,class,interface,abstract,private,public,protected,final
setlocal cinkeys=0{,0},0),!^F,o,O,e
setlocal nosmartindent " don't use smart indent option

1 个答案:

答案 0 :(得分:1)

您可以将选项设置为仅对特定文件生效。例如,我的vimrc中有以下内容:

if has("autocmd")
    augroup LISP
        au!
        au BufReadPost *.cl :set autoindent
    augroup END
    augroup C
        au!
        autocmd BufNewFile,BufRead *.cpp set formatprg=c:\\AStyle\\bin\\AStyle.exe\ -A4Sm0pHUk3s4
    augroup END
endif

使用这个,我可以打开自动注册,或文件格式化,或其他任何有意义的文件,但一般情况下没有,当它在其他情况下可能会烦扰我。在这种情况下,我打开.in文件的autoindent,但不一定是其他人。

理论上,你也可以使用相同的东西来关闭.txt文件的自动注册。

相关问题