首页 > 系统相关 >Linux 中设置vim编辑器编写shell脚本自动缩进

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

时间:2023-02-16 20:49:03浏览次数:35  
标签:autocmd 缩进 shell ts echo Linux vim

 

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

 

标签:autocmd,缩进,shell,ts,echo,Linux,vim
From: https://www.cnblogs.com/liujiaxin2018/p/17128207.html

相关文章