推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
pppy
V2EX  ›  Python

vim tab 键设置问题

  •  
  •   pppy · Mar 30, 2016 · 4263 views
    This topic created in 3830 days ago, the information mentioned may be changed or developed.

    :set tabstop=4

    ~/.vimrc 里已经这样设置了,但是有时候用 tab 键的时候不是四个空格,重新打开又可以了,是什么原因呢?

    8 replies  •  2016-03-31 10:41:09 +08:00
    SpicyCat
        1
    SpicyCat  
       Mar 30, 2016
    按理不应该这样。目前我知道影响 vim 的 tab 的有 editorconfig, 它可以根据文件类型设置 tabstop 。
    另外有些插件可能会设置。
    但是你说重新打开就又正常了,那就不是别的工具覆盖了你的设置。想不到原因。

    对了,你 shiftwidth 设置的多少?这个控制 auto indent 的大小。
    chemzqm
        2
    chemzqm  
       Mar 30, 2016   ❤️ 1
    有可能是被 setl 命令重新设置了, 出问题的时候输入 :verbose set tabstop
    查看是哪里设的
    nealnote
        3
    nealnote  
       Mar 30, 2016
    set et sw=4 ts=4 sts=4
    pppy
        4
    pppy  
    OP
       Mar 30, 2016
    @SpicyCat 对, 我有安装`editorconfig/editorconfig-vim`, 这个要怎么设置才能兼容呢?
    pppy
        5
    pppy  
    OP
       Mar 30, 2016
    @chemzqm 我有时候会用 set paste , 有影响吗
    SpicyCat
        6
    SpicyCat  
       Mar 30, 2016
    那要看你的 .editorconfig 文件是怎么写的了。看看里面 tab_width 的值是多少。
    另外 2 楼说得对,有可能是 setlocal 的问题
    chemzqm
        7
    chemzqm  
       Mar 30, 2016
    @pppy 有 tabstop 选项会被重置
    用 neovim ,你可以尝试 neovim ,它会自动切换粘贴模式
    wudanyang
        8
    wudanyang  
       Mar 31, 2016   ❤️ 1
    set autoindent " 自动缩进
    set smartindent " 智能缩进
    set tabstop=4 " tab 为 4 个空格
    set shiftwidth=4 " 设置行号
    set smarttab " 智能 tab
    set softtabstop=4 "
    来吧,放到你的 vimrc 文件中
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   834 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 20:36 · PVG 04:36 · LAX 13:36 · JFK 16:36
    ♥ Do have faith in what you're doing.