Linux 中设置vim编辑器编写shell脚本自动缩进

 

001、

打开vim的配置文件:vim ~/.vimrc

然后在其末尾增加如下内容, 然后保存退出:

if has("autocmd")
    filetype indent on
    autocmd FileType * setlocal ts=4 sts=4 sw=4 ai et nu
    autocmd FileType make setlocal ts=4 sts=4 sw=4 noet nu
endif

 

002、测试,可以实现shell自动缩进,并显示行号

  1 #!/bin/bash
  2 grep "s" a.txt > /dev/null
  3 if [ $? -eq 0 ]
  4 then
  5     echo "exit!"
  6 else
  7     echo "no exit!"
  8 fi

 

参考:https://blog.csdn.net/m0_56821563/article/details/128198148

 

posted @ 2023-02-16 20:29  小鲨鱼2018  阅读(244)  评论(0编辑  收藏  举报