本文主要是介绍VIM配置文件 .vimrc,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
其中一些内容参考了网络上的资料,放在这里只为方便使用,如有不合适,请和我沟通。
" ==========================================
" Filename : .vimrc
" Author : 肖清旺
" Email : dreamstone_xiaoqw@163.com
" Create : 2013-04-09 参考网络资料,开始学习
" Repair : 2013-07-04 优化出认为满意的脚本
" Repair : 2016-08-01 多年后,再次探究优化
" ==========================================
"==========================================================
" 显示行号
set nu
" 相对行号
set relativenumber
" 缩进 & 显示格式 & 开启终端色
set ai
set si
set ci
set ts=4
set sw=4
set textwidth=79
set shortmess=atI
if &term=="xterm"
set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
endif
" 光标
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
" 不生成烦人的W文件
set nobackup
set nowb
set report=0
" Autoadd
set nocp
" 插件
filetype plugin on
filetype plugin indent on
set tags+=tags
set autochdir
"-- 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()
set history=50
"==========================================================
这篇关于VIM配置文件 .vimrc的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!