还不是很完美:
"au BufReadPost * if line("'"") > 0|if line("'"") <= line("$")|exe("norm '"")|else|exe "norm $"|endif|endif augroup resCur "保存光标的位置,下次打开后返回该位置 autocmd! autocmd BufReadPost * call setpos(".",getpos("'"")) augroup END syntax on "语法高亮 "启用文件类型插件 filetype plugin on filetype indent on set hlsearch "搜索结果高亮 set incsearch "让搜索的动作像现代浏览器中一样 set background=dark hi CursorLine cterm=NONE ctermbg=236 ctermfg=NONE guibg=NONE guifg=NONE "hi CursorColumn cterm=NONE ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE hi LineNr cterm=NONE ctermbg=NONE ctermfg=1 guibg=NONE guifg=NONE set linespace=0 "字符间插入像素数 set sw=4 set ts=4 set et set sm set lbr set history=1000 "历史记录数 set cursorline "高亮光标所在行 "set cursorcolumn "高亮光标所在列 set ruler "显示标尺,即光标所在的位置 set go= "不要图形按钮 set nocompatible "与vi不兼容 set confirm "未保存退出时提示 set showcmd "输入的命令显示出来 "set clipboard+=unnamed set fenc=utf-8 set fencs=utf-8,gbk,gb2312,cp936,usc-bom,euc-jp set tabstop=4 set shiftwidth=4 set noexpandtab "不要使用空格替换tab set nu set autoindent set smartindent set cindent set showcmd "显示输入的命令 set cmdheight=1 "最下面的命令行的高度 set mouse=a set mousemodel=popup "set completeopt+=longest set nohlsearch "在搜索时忽略大小写 set novisualbell "不要闪烁 set whichwrap+=<,>,h,l "允许backspace和光标键跨越行边界 set foldmethod=syntax "自动折叠 "开关折叠 map <F3> za set foldlevel=99 "set nowrap "不要换行 "set nobackup "不要备份文件 set noerrorbells "不让vim发出滴滴声 set novisualbell set magic "正则表达式时开启魔术 set showmatch "高亮显示匹配的括号 "tab 和 shift tab用于多行的缩进和反缩进 nmap <tab> V> nmap <s-tab> V< vmap <tab> >gv vmap <s-tab> <gv nmap<F5> :w<CR>:call Do_OneKeyMake()<CR><c-l> imap<F5> <Esc>:w<CR>:call Do_OneKeyMake()<CR><c-l>i function Do_OneKeyMake() "let if=expand('%:p'); "let of=expand('%:p:h').'main' "let fe=expand('%:e') silent exec "!urxvt -hold -e g++ -Wall %" silent exec "!urxvt -hold -e ./a.out" "silent exec "!urxvt -hold -e ls -al" endfunction