Tab key == 4 spaces and auto-indent after curly braces in Vim

后端 未结 11 1575
自闭症患者
自闭症患者 2020-11-27 09:01

How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does?

11条回答
  •  执笔经年
    2020-11-27 09:24

    The auto-indent is based on the current syntax mode. I know that if you are editing Foo.java, then entering a { and hitting Enter indents the following line.

    As for tabs, there are two settings. Within Vim, type a colon and then "set tabstop=4" which will set the tabs to display as four spaces. Hit colon again and type "set expandtab" which will insert spaces for tabs.

    You can put these settings in a .vimrc (or _vimrc on Windows) in your home directory, so you only have to type them once.

提交回复
热议问题