我自己的vim配置:
set number "顯示行號(hào)"
set tabstop=4 "Tab鍵的寬度"
set softtabstop=4
set shiftwidth=4
set mouse=a
syntax on "語法高亮"
set autoindent
set showcmd "輸入的命令顯示出來,看的清楚些"
set cindent
set nobackup
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"
"定義函數(shù)SetTitle老厌,自動(dòng)插入文件頭"
func SetTitle()
"如果文件類型為.sh文件"
if &filetype == 'sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name : ".expand("%"))
call append(line(".")+1, "\# Description : ")
call append(line(".")+2, "\# Author : Qreal")
call append(line(".")+3, "\# Mail : 1336529610@qq.com")
call append(line(".")+4, "\# Created Time : ".strftime("%Y-%m-%d %H:%M:%S"))
call append(line(".")+5, "\# Last modified: ".strftime("%Y-%m-%d %H:%M:%s"))
call append(line(".")+6, "\#########################################################################")
call append(line(".")+7, "\#!/bin/bash")
call append(line(".")+8, "")
else
call setline(1, "/*************************************************************************")
call append(line("."), " > File Name : ".expand("%"))
call append(line(".")+1, " > Description : ")
call append(line(".")+2, " > Author : Qreal")
call append(line(".")+3, " > Mail : 1336529610@qq.com ")
call append(line(".")+4, " > Created Time : ".strftime("%Y-%m-%d %X"))
call append(line(".")+5, " > Last modified: ".strftime("%Y-%m-%d %X"))
call append(line(".")+6, " ************************************************************************/")
call append(line(".")+7, "")
endif
if &filetype == 'cpp'
call append(line(".")+8, "#include<iostream>")
call append(line(".")+9, "using namespace std;")
call append(line(".")+10, "")
endif
if &filetype == 'c'
call append(line(".")+8, "#include<stdio.h>")
call append(line(".")+9, "")
endif
"新建文件后菌瘪,自動(dòng)定位到文件末尾"
autocmd BufNewFile * normal G
endfunc
"""""""""""""""""""""""""""""""""""""""""
"實(shí)現(xiàn)上面函數(shù)中的,Last modified功能"
"""""""""""""""""""""""""""""""""""""""""
autocmd BufWrite,BufWritePre,FileWritePre *.c ks|call LastModified()|'s
func LastModified()
if line("$") > 20
let l = 20
else
let l = line("$")
endif
exe "1,".l."g/Last modified: /s/Last modified: .*/Last modified:".
\strftime(" %Y-%m-%d %X" ) . "/e"
endfunc
在網(wǎng)上搜索了很多內(nèi)容乌叶,參考了論壇上的一些代碼,給配置了一個(gè)柒爸,用著覺得還不錯(cuò)。