Setting Vim whitespace preferences by filetype

前端 未结 5 1340
遇见更好的自我
遇见更好的自我 2020-12-04 04:50

At my work, I am required to follow the house style for indentation, which goes as follows:

  • 2 spaces when coding html and ruby
  • tabs when coding javasc
5条回答
  •  自闭症患者
    2020-12-04 05:25

    To insert space characters whenever the tab key is pressed, set the 'expandtab' option:

    :set expandtab
    

    Next step is to control the number of space characters that will be inserted when the tab key is pressed, set the 'tabstop' option. For example, to insert 2 space for a tab, use:

    :set tabstop=2
    

    ref: http://vim.wikia.com/wiki/Converting_tabs_to_spaces

提交回复
热议问题