vim 配置文件 ,vimrc 脚本(Linux,Mac OS都可以用)

"    Filename    :       .vimrc
"    Author      :       弈心逐梦 yixzm
"    Email       :       dreamstone_xiaoqw@163.com
"    Create      :       2013-04-09 参考网络资料,开始学习
"    Repair      :       2013-07-04 优化出认为满意的脚本
"    Repair      :       2016-08-01 多年后,再次探究优化
"    Repair      :       2017-08-31 根据现有使用习惯,总结

" 显示行号
set nu
" 相对行号
set relativenumber
" 注::vim7.2版本默认不可用。
" 缩进 & 显示格式 & 开启终端色

set ai
set si
set ci
set ts=4
set sw=4
set textwidth=79
set shortmess=atIif &term=="xterm"  
set t_Co=8 
  set t_Sb=^[[4%dm    set t_Sf=^[[3%dmendif

" 重要!!!在Mac电脑中,缺少会导致没有颜色
syntax on
" 光标
set cursorline
set cursorcolumn
" 状态栏
set cmdheight=2
set laststatus=2
set scrolloff=5
""set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 搜索
set incsearch
" 不生成.swp文件
set nobackup
set nowb
set report=0
" Autoadd
set nocp
" 插件
filetype plugin on
filetype plugin indent on
set tags+=tags
set autochdir
set history=50

"   inoremap ' ''<Esc>i
 "   inoremap " ""<Esc>i
 "   inoremap < <><Esc>i
 "   inoremap ( ()<Esc>i
 "   inoremap [ []<Esc>i
 "   inoremap { {<CR>}<Esc>O
这几行是自动添加匹配的括号,现在不怎么写C++代码,所以我自己也不开启。
"===============================================================================
"分隔线:此后的内容尽量不加,时间久没有用了,我自己平时也基本用不上。
"===============================================================================
"-- omnicppcomplete setting --
set completeopt=menu,preview
set completeopt-=preview
set completeopt=longest,menu
let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1
" show function prototype  in popup window
let OmniCpp_GlobalScopeSearch=1
let OmniCpp_DisplayMode=1
let OmniCpp_DefaultNamespaces=["std"]
function Myadd()
    inoremap ' ''<Esc>i
    inoremap " ""<Esc>i
    inoremap < <><Esc>i
    inoremap ( ()<Esc>i
    inoremap [ []<Esc>i
    inoremap { {<CR>}<Esc>O

inoremap > <c-r>=ClosePair('>')<CR>
    inoremap ) <c-r>=ClosePair(')')<CR>
    inoremap ] <c-r>=ClosePair(']')<CR>
""    inoremap } <c-r>=CloseBracket('}')<CR>
    inoremap " <c-r>=QuoteDelim('"')<CR>
    inoremap ' <c-r>=QuoteDelim("'")<CR>
endfunction
function Mydel()
    inoremap ' '
    inoremap " "
    inoremap < <
    inoremap ( (
    inoremap [ [
    inoremap { {
endfunction
function ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "<Right>"
    else
        return a:char
    endif
endf
function CloseBracket()
    if match(getline(line('.') + 1), 's*}') < 0
        return "<CR>}"
    else
        return "<Esc>j0f}a"
    endif
endf
function QuoteDelim(char)
    let line = getline('.')
    let col = col('.')
    if line[col - 2] == "\"
        "Inserting a quoted quotation mark into
        the string
        return a:char
    elseif line[col - 1] == a:char
        "Escaping out of the string
        return "<Right>"
    else
        "Starting a string
        return a:char.a:char."<Esc>i"
    endif
endfunction
"    Colorconfig
syntax enable
syntax on
colorscheme default
set nohls
"     Templetes
""autocmd BufRead,BufNewFile *.h set filetype=c
""let g: C_SourceCodeExtensions = 'h c cp ...'
"      :help c-support-comm-frame
let g:SuperTabDefaultCompletionType="context"
"    Inoremap
inoremap <F7> <Esc>:call Myadd()<CR>a
inoremap <F8> <Esc>:call Mydel()<CR>a
inoremap <F2> <Esc>:TlistOpen<CR>a
inoremap <F3> <Esc>:TlistClose<CR>a
"    Default
call Myadd()

"=========================================================

版权声明

弈心博客


本文首发site_name,转载请附上博文链接!