1.通过gedit .rmvic进入vi编程配置文件,将下面的指令复制粘贴进去保存退出就可以了
(可以根据需要修改其中的名字,邮箱等)
"set mouse-=a
set nu
syntax on
syntax enable
colorscheme desert
" TagList
let Tlist_Show_One_File=1
let Tlist_Exit_onlyWindow=1
" WinManager
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle
" Omnicompletion
set nocp
filetype plugin indent on
set completeopt=longest,menu
" Indent
set smartindent
set expandtab
" 自动缩进
set autoindent
set cindent
" Tab键的宽度
set tabstop=4
" 统一缩进为4
set softtabstop=4
set shiftwidth=4
" 将tab替换为空格
nmap tt :%s/t/ /g
set foldenable " 允许折叠
set foldmethod=manual " 手动折叠
nmaps :cs find s =expand(" ")
nmapg :cs find g =expand(" ")
nmapc :cs find c =expand(" ")
nmapt :cs find t =expand(" ")
nmape :cs find e =expand(" ")
nmapf :cs find f =expand(" ")
nmapi :cs find i ^ =expand(" ") $
nmapd :cs find d =expand(" ")
autocmd BufNewFile *.[ch],*.hpp,*.cpp exec ":call SetTitle()"
"加入注释
func SetComment()
call setline(1,"")
endfunc
"定义函数SetTitle,自动插入文件头
func SetTitle()
call SetComment()
if expand("%:e") == 'hpp'
call append(line(".")+10, "#ifndef _".toupper(expand("%:t:r"))."_H")
call append(line(".")+11, "#define _".toupper(expand("%:t:r"))."_H")
call append(line(".")+12, "#ifdef __cplusplus")
call append(line(".")+13, "extern "C"")
call append(line(".")+14, "{")
call append(line(".")+15, "#endif")
call append(line(".")+16, "")
call append(line(".")+17, "#ifdef __cplusplus")
call append(line(".")+18, "}")
call append(line(".")+19, "#endif")
call append(line(".")+20, "#endif //".toupper(expand("%:t:r"))."_H")
elseif expand("%:e") == 'h'
call append(line(".")+10, "#endif")
call append(line(".")+10, "")
call append(line(".")+10, "#ifndef _".toupper(expand("%:t:r"))."_H")
call append(line(".")+11, "#define _".toupper(expand("%:t:r"))."_H")
elseif &filetype == 'c'
" call append(line(".")+10,"#include")
" call append(line(".")+10,"#include")
" call append(line(".")+10,"#include")
call append(line(".")+6,"#include")
call append(line(".")+7,"")
call append(line(".")+8,"int main(int argc, char *argv[])")
call append(line(".")+9,"{ " )
call append(line(".")+10,"" )
call append(line(".")+11," return 0;")
call append(line(".")+12,"} ")
elseif &filetype == 'cpp'
call append(line(".")+10,"#include")
call append(line(".")+10,"using namespace std;")
endif
endfunc
"新建文件后,自动定位到文件第10行
autocmd BufNewFile * normal 10gg
set termencoding=utf-8
set encoding=utf8
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030
新建界面格式如下
1
8 #include
9
10 int main(int argc, char *argv[])
11 {
12
13 return 0;
14 }



