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

==========================================
” Filename : .vimrc
” Author : 弈心逐梦 yixzm
” Email : [email protected]
” Create : 2013-04-09 参考网络资料,开始学习
” Repair : 2013-07-04 优化出认为满意的脚本
” Repair : 2016-08-01 多年后,再次探究优化
” Repair : 2017-08-31 根据现有使用习惯,总结
” Repair : 2017-09-19 Markdown编辑器重新整理
==========================================

显示行号

set nu

显示相对行号(方便使用ndd,nyy等命令)

set relativenumber 

注:相对行号的设置vim7.2版本默认不可用。

自动缩进(auto),智能缩进(smart),C格式缩进

set ai
set si
set ci

table键缩进长度,换行缩进长度

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

开启语法高亮(即编程语言关键字彩色显示)

syntax enable
syntax on

重要!!!在Mac电脑中,缺少syntax on会导致关键字不显示颜色

显示横、纵坐标的光标

set cursorline
set cursorcolumn

状态栏

set cmdheight=2
set laststatus=2

光标距离底行的距离,体验很不错

set scrolloff=5

可以使用鼠标。在远程telnet或ssh的场景下也有效。

set mouse=a 
set selection=exclusive
set selectmode=mouse,key

搜索时不区分大小写

set incsearch

不生成.swp文件

set nobackup
set nowb
set report=0

” Autoadd

set nocp

设置颜色风格

colorscheme default

颜色风格可换知乎大V推荐的款式:slate、evening、desert、koehler等

取消高亮,否则会经常出现色块

set nohls

插件

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 ' ''i
    inoremap " ""i
    inoremap < <>i
    inoremap ( ()i
    inoremap [ []i
    inoremap { {}O

    inoremap > =ClosePair('>')
    inoremap ) =ClosePair(')')
    inoremap ] =ClosePair(']')
""    inoremap } =CloseBracket('}')
    inoremap " =QuoteDelim('"')
    inoremap ' =QuoteDelim("'")
endfunction
function Mydel()
    inoremap ' '
    inoremap " "
    inoremap < <
    inoremap ( (
    inoremap [ [
    inoremap { {
endfunction
function ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "\"
    else
        return a:char
    endif
endf
function CloseBracket()
    if match(getline(line('.') + 1), '\s*}') < 0
        return "\}"
    else
        return "\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 "\"
    else
        "Starting a string
        return a:char.a:char."\i"
    endif
endfunction
"    Colorconfig

"     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  :call Myadd()a
inoremap  :call Mydel()a
inoremap  :TlistOpena
inoremap  :TlistClosea
"    Default
call Myadd()

“=========================================================
“`

你可能感兴趣的:(运维)