我自己的vim配置:
set number "显示行号"
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()"
"定义函数SetTitle,自动插入文件头"
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
"新建文件后,自动定位到文件末尾"
autocmd BufNewFile * normal G
endfunc
"""""""""""""""""""""""""""""""""""""""""
"实现上面函数中的,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
在网上搜索了很多内容,参考了论坛上的一些代码,给配置了一个,用着觉得还不错。
网友评论