Setting Vim whitespace preferences by filetype

前端 未结 5 1342
遇见更好的自我
遇见更好的自我 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:32

    there are many ways, but here's a simple, easy to understand way. add these lines to your ~/.vimrc:

    autocmd FileType html setlocal ts=2 sts=2 sw=2
    autocmd FileType ruby setlocal ts=2 sts=2 sw=2
    autocmd FileType javascript setlocal ts=4 sts=4 sw=4
    

提交回复
热议问题