一:语法高亮
syntax on(设置语法高亮)
syntax off(关闭语法高亮)
二:显示行号
set number(设置行号)
set nonumber(关闭行号)
三:自动缩进
set autoindent
set cindent
四:自动加入文件头:(将如下的代码添加进/etc/vimrc配置文件中即可实现自动加入文件头的操作)
autocmd BufNewFile *.py,*.sh, exec ":call SetTitle()"
let $author_name = "xxxx"
let $author_email = "xxxx@xxx.xx"
func SetTitle()
if &filetype == 'sh'
call setline(1,"\###################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: ".$author_name)
call append(line(".")+2, "\# mail: ".$author_email)
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#=============================================================")
call append(line(".")+5, "\#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1,"\###################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: ".$author_name)
call append(line(".")+2, "\# mail: ".$author_email)
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#=============================================================")
call append(line(".")+5, "\#!/usr/bin/python")
call append(line(".")+6, "")
endif
endfunc
Shell高亮显示
基本格式:
echo -e 终端颜色 + 显示内容 + 结束后颜色
echo -e "\e[1;30m jeson say Hi~ \e[1;0m"
网友评论