gpt4 book ai didi

vim - 为什么即使未设置文件类型,Vim 也使用 Bash 缩进规则?

转载 作者:行者123 更新时间:2023-12-04 23:30:05 26 4
gpt4 key购买 nike

我有一个令人困惑的 Vim 问题。如果我开始编辑一个新文件,用 vim test.txt 说,然后我输入单词“do”并按回车键(仍处于插入模式时),下一行将自动缩进。在给出快速答案之前,请阅读整篇文章。

两个问题:

  • 为什么会发生这种情况?
  • 如何调试启动过程(读取 ~/.vimrc 和 ~/.vim/中的文件)?

  • 更多信息:
  • 这是我的 .vimrc:http://dotfiles.org/~meonkeys/.vimrc .
  • “do”、“if”和“switch”都会导致缩进,但我仍然没有弄清楚 Vim 使用缩进规则的语言是什么。
  • 我确实在 ~/.vim/中有一堆东西。这是:http://adammonsen.com/tmp/dot_vim.tgz
  • 我在 ~/.vimrc 或 ~/.vim/中找不到任何应该打开某种缩进的内容,即使 filetype未设置!
  • 如果我使用 vim -u /dev/null test.txt 启动 Vim ,问题就迎刃而解了。
  • 是的,我知道 autoindent环境。我不认为这是问题,因为打开 autoindent使用空 vimrc 后,在输入“do”后不缩进该行。
  • 最佳答案

    '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, setting 'si' has no effect.
    'indentexpr' is a more advanced alternative.
    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).

    cinwords 默认为 if,else,while,do,for,switch

    关于vim - 为什么即使未设置文件类型,Vim 也使用 Bash 缩进规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6418348/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com