1 set nu "序號 2 set tabstop=4 "tab鍵的大小 3 set showcmd 4 nnoremap <F2> :set nonumber!<CR>:set foldcolumn=0<CR> "用F2開關數字,方便複製 5 6 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 7 "建立.c,.h,.sh,.java檔案,自動插入檔案頭 8 autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()" 9 ""定義函數SetTitle,自動插入檔案頭 10 func SetTitle() 11 "如果檔案類型為.sh檔案 12 if &filetype == ‘sh‘ 13 call setline(1,"\#########################################################################") 14 call append(line("."), "\# File Name: ".expand("%")) 15 call append(line(".")+1, "\#[email protected] Author:Panhao_Neo ") "這裡是著作權名(作者)16 call append(line(".")+2, "\# mail: [email protected]") "郵箱17 call append(line(".")+3, "\# Created Time: ".strftime("%c"))18 call append(line(".")+4, "\#########################################################################")19 call append(line(".")+5, "\#!/bin/bash")20 call append(line(".")+6, "")21 else22 call setline(1, "/*************************************************************************")23 call append(line("."), " > File Name: ".expand("%"))24 call append(line(".")+1, " > [email protected] Author:Panhao_Neo ") 25 call append(line(".")+2, " > Mail: [email protected] ")26 call append(line(".")+3, " > Created Time: ".strftime("%c"))27 call append(line(".")+4, " ************************************************************************/")28 call append(line(".")+5, "")29 endif30 if &filetype == ‘cpp‘31 call append(line(".")+6, "#include<iostream>")32 call append(line(".")+7, "using namespace std;")33 call append(line(".")+8, "")34 endif35 if &filetype == ‘c‘36 call append(line(".")+6, "#include<stdio.h>")37 call append(line(".")+7, "int main()")38 call append(line(".")+8, "{")39 call append(line(".")+9, " ")40 call append(line(".")+10, "}")41 endif42 " if &filetype == ‘java‘43 " call append(line(".")+6,"public class ".expand("%"))44 " call append(line(".")+7,"")45 " endif46 "建立檔案後,自動定位到檔案末尾47 autocmd BufNewFile * normal G48 endfunc