1
4

2 回答 2

1

你需要set ai

来自帮助:

'autoindent' 'ai'       boolean (default off)
                        local to buffer
        Copy indent from current line when starting a new line (typing <CR>
        in Insert mode or when using the "o" or "O" command).  If you do not
        type anything on the new line except <BS> or CTRL-D and then type
        <Esc>, CTRL-O or <CR>, the indent is deleted again.  Moving the cursor
        to another line has the same effect, unless the 'I' flag is included
        in 'cpoptions'.
        When autoindent is on, formatting (with the "gq" command or when you
        reach 'textwidth' in Insert mode) uses the indentation of the first
        line.
        When 'smartindent' or 'cindent' is on the indent is changed in
        a different way.
        The 'autoindent' option is reset when the 'paste' option is set.
        {small difference from Vi: After the indent is deleted when typing
        <Esc> or <CR>, the cursor position when moving up or down is after the
        deleted indent; Vi puts the cursor somewhere in the deleted indent}.

注意

如果您没有在新行中键入除 <BS> 或 CTRL-D 之外的任何内容,然后键入 <Esc>、CTRL-O 或 <CR>,缩进将再次被删除。

于 2013-09-11T20:34:52.283 回答
0

好吧,结果证明是一个狡猾的插件导致了这个问题。

我应该--noplugins早些时候尝试过(不知道那个选项)。

我一直在使用“ ctab.vim ”插件。禁用它可以解决问题。

此外,Konstantin Lepa 在此站点上提供了针对此问题的错误修复:http://vim.wikia.com/wiki/Script: 231

于 2013-09-11T22:29:07.480 回答