1. 程式人生 > >vim編輯器頭部自動插入註釋

vim編輯器頭部自動插入註釋

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:      
[email protected]
") 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:      [email protected]")
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的高亮顯示