vim 编辑器配置

来源:互联网 发布:c语言产生随机数的方法 编辑:程序博客网 时间:2024/06/06 02:16

命令sudo vim  /etc/vim/vimrc

在文件结尾加如下语句:


"启用行号set nu"table 键长度 set tabstop=4"取消自动备份set nobackupset cursorlineset ruler"自动匹配set autoindent   syntax on"智能匹配set smartindent"统一缩进为4set shiftwidth=4set showmatchset guioptions-=T"搜索逐个字符高亮set hlsearchset incsearchset nocompatibleset backspace=2set number"括号匹配inoremap ( ()<ESC>i"inoremap ) <c-r>=ClosePair(')')<CR>inoremap [ []<ESC>i"inoremap ] <c-r>=ClosePair(']')<CR>inoremap { {<CR>}<ESC>kA<CR>"inoremap } <c-r>=ClosePair('}')<CR>inoremap < <><ESC>i"inoremap > <c-r>=ClosePair('>')<CR>inoremap " ""<ESC>i"inoremap " <c-r>=ClosePair('"')<CR>inoremap ' ''<ESC>i"自动补全set completeopt=preview,menuset completeopt=longest,menu"启用鼠标set mouse=a"set selection=exclusive"set selectmode=mouse,key"设置编码自动识别set fileencoding=utf-8set ambiwidth=doubleset hlsearchcolorscheme desert"自动补全命令时候使用菜单式匹配列表set wildmenu""autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete""autocmd FileType Python set omnifunc=python=pythoncomplete#Complete""autocmd FileType javascript set omnifunc=javascriptcomplete#Complete""autocmd FileType html set omnifunc=htmlcomplete#Complete""autocmd FileType css set omnifunc=csscomplete#Complete""autocmd FileType xml set omnifunc=xmlcomplete#Complete""autocmd FileType java set omnifunc=javacomplete#Complete""set ofu=syntaxcomplete#Complete""imap <silent> ' <C+X><C+O>"历史记录数"set history=1000"行内替换set gdefault"总是显示状态行set laststatus=2"增强模式中的命令行自动完成操作"set wildmenu"允许backspace和光标键跨越边界set whichwrap+=<,>,h,l:set backspace=indent,eol,startset noexpandtab"c++的编译和运行map <F6> :call CompileRunGpp()<CR>func! CompileRunGpp()exec "w"exec "!g++ % -o %<"exec "! ./%<"endfuncmap <F4> :call TitleDet2()<cr>'sfunction AddTitle2()call append(0,"/*****************************************************")call append(1," * Author        : skyblue")call append(2," * Email         : tianyuskyblue@gmail.com ")call append(3," * Last modified : ".strftime("%y-%m-%d %H:%M"))call append(4," * Filename      : ".expand("%:t") )call append(5," * Description   : ")call append(6," * **************************************************/")echohl WarningMsg | echo "Successful in adding the copyright." | echohl Noneendf"更新最近修改时间和文件名function UpdateTitle2()normal m'execute '/# *Last modified:/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M")@'    normal ''normal mkexecute '/# *Filename:/s@:.*$@\=":\t\t".expand("%:t")@'execute "noh"normal 'kechohl WarningMsg | echo "Successful in updating the copy right." | echohl Noneendfunction"判断前7行代码里面,是否出现Last modified这个词,没有重新添加,有更新即可function TitleDet2()let n = 1"默认添加while n < 7let line = getline(n)if line =~'^\#\s*\S*Last\smodified:\S*.*$'call UpdateTitle2()returnendiflet n = n + 1endwhilecall AddTitle2()endfunctionmap <F5> :call  TitleDet3()<cr>'sfunction AddTitle3()call append(8,"#include <iostream>") call append(9,"#include <cstdio>")call append(10,"#include <string>")call append(11,"#include <cstring>")call append(12,"#include <algorithm>")call append(13,"#include <stdlib.h>")call append(14,"#include <iomanip>")call append(15,"#include <fstream>") call append(16,"#include <cmath>")call append(17,"#include <queue>")call append(18,"#include <stack>")call append(19,"#include <set>")call append(20,"#include <map>")call append(21,"#include <vector>")call append(22,"#include <iostream>") call append(23,"      ")call append(24,"using namespace std;")call append(25,"#pragma comment(linker ,\"/STACK:102400000,102400000\")")call append(26,"#define maxn 10000010")call append(27,"#define LL long long")call append(28,"#define ULL unsigned long long")call append(29,"#define mem(a , b) memset(a , b , sizeof(b))")call append(30,"#define FOR(i , n) for(int i = 1 ; i <= n ; i ++)")call append(31,"typedef pair<int , int> pii;")call append(32,"  ")call append(33,"int main()")call append(34,"{")call append(35," ")call append(36,"return 0;")call append(37,"}")echohl WarningMsg | echo "Successful in adding the titilefile." | echohl Noneendffunction TitleDet3()let n = 8"默认添加while n < 12let line = getline(n)if line =~'^\#\s*\S*#include:\S*.*$'returnendiflet n = n + 1endwhilecall AddTitle3()endfunction


0 0