vim编辑器头部自动插入注释和shell的高亮显示
程序员文章站
2022-06-25 08:10:11
1.基本语法 2.自动加入文件头 在etc/vimic 源码: 3.修改为不提示自动创建(也可以提示自动创建) 源码: 3.shell的高亮显示 ......
1.基本语法
语法高亮 :syntax on/off 显示行号 set number/nonumber 自动缩进 set autoindent set cindent
2.自动加入文件头
在etc/vimic
源码:
## 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>
3.修改为不提示自动创建(也可以提示自动创建)
源码:
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的高亮显示