在vim

时间:2017-03-03 20:13:23

标签: vim

我只是习惯了Vim,我现在非常享受它。但我现在正在shift-o处理一个奇怪的问题。我觉得它应该保持一致,但是当我使用命令时它会向左侧选择2次。这是一个截图:

在Shift-o之前:

enter image description here

Shift-o

之后

enter image description here

正如你所看到的,它向前跳跃。我希望它留在原地,然后上去。我能以任何方式做到这一点吗?

.vimrc中:

set tabstop=2
set number
set nowrap

1 个答案:

答案 0 :(得分:2)

添加

set smartindent

.vimrc。来自:h smartindent

                 *'smartindent'* *'si'* *'nosmartindent'* *'nosi'*
'smartindent' 'si'  boolean (default off)
            local to buffer
            {not in Vi}
            {not available when compiled without the
            |+smartindent| feature}
    Do smart autoindenting when starting a new line.  Works for C-like
    programs, but can also be used for other languages.  'cindent' does
    something like this, works better in most cases, but is more strict,
    see |C-indenting|.  When 'cindent' is on or 'indentexpr' is set,
    setting 'si' has no effect.  'indentexpr' is a more advanced
    alternative.

您应该考虑添加

set autoindent

.vimrc。这是没有必要的,只是推荐。事实上,如果你进一步向下滚动,vim-help本身会推荐这个:

    Normally 'autoindent' should also be on when using 'smartindent'.
    An indent is automatically inserted:
    - After a line ending in '{'.
    - After a line starting with a keyword from 'cinwords'.
    - Before a line starting with '}' (only with the "O" command).