vim编写yaml配置

hwwjian

关注

阅读 102

2022-07-12

在实际工作中,需要使用vim编写yaml文件和python文件,这些文件对缩进非常敏感,如果空格和TAB一起用的话,文件一般就会报错。所以针对文件编写,需要进行配置

vim ~/.vimrc
atuocmd FileType yaml setlocal ai nu ru ts=2 sw=2 et
atuocmd FileType python setlocal ai nu ru ts=2 sw=2 et
soucre ~/.vimrc

说明:

  1. autocmd FileType 检测文件类型为yaml或者python
  2. ai =auto indent,自动缩进
  3. set tabstop=2(ts=tabstop,即一个tab的宽度被设为2个空格宽)
  4. set shiftwidth=2(sw=shiftwidth,即退格对齐以2个空格为准)
  5. set expandtab(et=expandtab,将tab变成空格)
  6. set nu ,set number,显示行号
  7. set ru,set ruler,显示标尺,可以显示行列,方便对齐​

精彩评论(0)

0 0 举报