为更加高效使用vim工具,快捷完成工作任务,对vim进行简单配置
方法:修改/etc/vimrc文件(永久修改)
在原来vimrc文件基础上,添加以下内容
"add by Rubin"
syntax on"设置高亮"
set autoindent"自动对齐"
set cindent"自动对齐"
"set cursorline"
set ru"设置行号"
set number"设置行号"
set cursorcolumn"设置竖行选中"
"自动插入文件头 .sh .cpp .c "
autocmd BufNewFile *.sh,*.cpp,*.c exec ":call SetTitle()"
let $author_name="Rubin"
let $author_email="cheng_yong_bin@163.com"
func SetTitle()
if &filetype=='sh'
call setline(1,"\########################################")
call append(line("."),"\# File Name:".expand("%"))
call append(line(".")+1,"\# Author:".$author_name)
call append(line(".")+2,"\# E-mail:".$author_email)
call append(line(".")+3,"\# Created Time:".strftime("%c"))
call append(line(".")+4,"\# ======================================")
call append(line(".")+5,"\#!/bin/bash")
call append(line(".")+6,"")
else
call setline(1, "/****************************************")
call append(line("."), " > File Name: ".expand("%"))
call append(line(".")+1, " > Author:".$author_name)
call append(line(".")+2, " > E-mail:".$author_email)
call append(line(".")+3, " > Created Time: ".strftime("%c"))
call append(line(".")+4, " ***************************************************/")
call append(line(".")+5, "")
endif
if &filetype=='cpp'
call append(line(".")+6, "#include<iostream>")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
endif
if &filetype=='c'
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
endif
autocmd InsertLeave * se nocul"当前行高亮"
autocmd InsertEnter * se cul"当前行高亮"
autocmd BufNewFile * normal G"新建文件后,自动定位到文件末尾"
endfunc
//以上仅为部分配置项,其他配置因未用到暂未列出;
//其他配置可以参考以下两个blog
参考1:http://lhsblog01.blog.163.com/blog/static/102004519201122072243490/
参考2:http://www.jb51.net/LINUXjishu/95323.html
实例参考:gitHub