vim编辑器头部自动插入注释和shell的高亮显示

时间:2021-01-19 17:57:46

1.基本语法

语法高亮
:syntax on/off
显示行号
set number/nonumber 自动缩进
set autoindent
set cindent

2.自动加入文件头

在etc/vimic

vim编辑器头部自动插入注释和shell的高亮显示

vim编辑器头部自动插入注释和shell的高亮显示

源码:

## vim 头部自动生成
function AddTitle()
call setline(1,"#!/usr/bin/env bash")
call append(1,"# -*- coding: utf-8 -*-")
call append(2,"#Filename: " . expand("%"))
call append(3,"#Author: Liuchao")
call append(4,"#Email: 137642091@qq.com")
call append(5,"#Date: " . strftime("%Y-%m-%d"))
call append(6,"#Desc: ")
call append(7,"")
call append(8,"source /devOps/shell/common/functions")
call append(9," ")
endf ## 提示按'F4',会调用AddTitle函数
map <F4> : call AddTitle() <cr>

vim编辑器头部自动插入注释和shell的高亮显示

3.修改为不提示自动创建(也可以提示自动创建)

vim编辑器头部自动插入注释和shell的高亮显示

源码:

autocmd BufNewFile *.php,*.sh exec ":call AddTitle()"

function AddTitle()
call setline(1,"#!/usr/bin/env bash")
call append(1,"# -*- coding: utf-8 -*-")
call append(2,"#Filename: " . expand("%"))
call append(3,"#Author: Liuchao")
call append(4,"#Email: 137642091@qq.com")
call append(5,"#Date: " . strftime("%Y-%m-%d"))
call append(6,"#Desc: ")
call append(7,"")
call append(8,"source /devOps/shell/common/functions")
call append(9," ")
endf

3.shell的高亮显示

vim编辑器头部自动插入注释和shell的高亮显示

vim编辑器头部自动插入注释和shell的高亮显示

vim编辑器头部自动插入注释和shell的高亮显示