拾遗:vim 配置(个人适用,仅供参考)

~/.vimrc

  1 "===================通用配置======================
  2 set encoding=utf-8
  3 
  4 set statusline=%F%=[Line:%l/%L,Column:%c] "显示文件名、行数
  5 "set statusline=[%F]%r%m%*%=[Line:%l/%L,Column:%c][%p%%] "显示文件名:总行数,总的字符数
  6 set ruler "在编辑过程中,在右下角显示光标位置的状态行
  7 
  8 " 控制
  9 set nocompatible              "关闭vi兼容
 10 filetype off                  "关闭文件类型侦测,vundle需要
 11 set fileencodings=utf-8       "使用utf-8
 12 syntax on                     "语法高亮
 13 set backspace=2               "退格键正常模式
 14 "set whichwrap=<,>,[,]         "当光标到行首或行尾,允许左右方向键换行
 15 set autoread                  "文件在vim外修改过,自动重载      
 16 set nobackup                  "不使用备份
 17 set confirm                   "在处理未保存或只读文件时,弹出确认消息   
 18 set scrolloff=3               "光标移动到距离顶部或底部开始滚到距离
 19 set history=1000              "历史记录数
 20 set mouse=                    "关闭鼠标
 21 set selection=inclusive       "选择包含最后一个字符
 22 set selectmode=mouse,key      "启动选择模式的方式
 23 "set completeopt=longest,menu  "智能补全,弹出菜单,无歧义时才自动填充
 24 set noswapfile                "关闭交换文件
 25 set hidden                    "允许在有未保存的修改时切换缓冲区
 26 
 27 "显示
 28 colorscheme desert           "选择配色方案
 29 set t_Co=256                  "可以使用的颜色数目
 30 set number                    "显示行号
 31 set laststatus=2              "显示状态行
 32 set ruler                     "显示标尺
 33 set showcmd                   "显示输入的命令
 34 set showmatch                 "高亮括号匹配
 35 set matchtime=1               "匹配括号高亮的时间(十分之一秒)
 36 set matchpairs={:},(:),[:],<:>        "匹配括号"{}""()"...等    
 37 set hlsearch                  "检索时高亮匹配项
 38 set incsearch                 "边检索边显示匹配
 39 "set go-=T                     "去除gvim的toolbar
 40 
 41 "格式
 42 set noexpandtab               "不要将tab转换为空格
 43 set shiftwidth=4              "自动缩进的距离,也是平移字符的距离
 44 set tabstop=4                 "tab键对应的空格数
 45 set autoindent                "自动缩进
 46 set smartindent               "智能缩进
 47 
 48 "===================按键映射======================
 49 
 50 "按键映射的起始字符
 51 let mapleader = '\'             
 52 
 53 "使用Ctrl-l 和 Ctrl+h 切换标签页
 54 nnoremap <C-l> gt            
 55 nnoremap <C-h> gT
 56 "open and close tab
 57 nnoremap <C-n> :tabnew<CR>
 58 nnoremap <C-k> :tabc<CR>
 59 
 60 "在行末加上分号
 61 "map! <F9> <Esc>A<Space>;<CR>
 62 
 63 "===================插件管理======================
 64 
 65 " 下载pathogen
 66 " git clone --depth 1 https://gitee.com/kt10/vim-pathogen.git /tmp/abcdef && mv /tmp/abcdef/autoload ~/.vim/
 67 
 68 " 自动配对括号
 69 " git clone --depth 1 git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs
 70 
 71 " 目录管理器
 72 " git clone --depth 1 https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
 73 
 74 "tagbar 插件
 75 " git clone --depth 1 https://github.com/majutsushi/tagbar.git ~/.vim/bundle/tagbar
 76 
 77 "gotags:显示 go 的tagbar
 78 "go get -u github.com/jstemmer/gotags
 79 "go install
 80 
 81 " 下载 YCM 及其附属模块源码
 82 "git clone --depth 1 https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
 83 "git submodule update --init --recursive
 84 
 85 " 编译安装全功能 YCM (需要首先安装最新版本的 clang 库:libclang.so);也可以使用自带的脚本安装,如仅安装 go 的语义补全:./install.py  --gocode-completer
 86 "step0: cd $BuildDir \
 87 "step1: cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/PATH/TO/LLVM_Root_Dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp \
 88 "step2: make
 89 
 90 " YCM 常用命令
 91 "    :YcmRestartServer  重启 YCM 服务器
 92 "    :YcmCompleter  显示可用的子命令
 93 "    :YcmCompleter GetParent  显示父函数、父类等
 94 "    :YcmCompleter GetType  显示类型、参数等信息
 95 "    :YcmCompleter GetDoc  跳转至相关文档(若有)
 96 "    :YcmCompleter GoToDeclaration  跳转至声明处
 97 "    :YcmCompleter GoToDefinition  跳转至定义处
 98 "    :YcmCompleter GoToInclude  跳转至头文件处
 99 
100 filetype plugin indent on    " required
101 
102 "===================插件配置======================
103 
104 "-----pathogen-----
105 execute pathogen#infect() 
106 
107 "-----NERDTree-----
108 let g:NERDTreeCaseSensitiveSort = 1
109 let g:NERDTreeWinSize = 32
110 let g:NERDTreeWinPos = "left"
111 nnoremap <F5> :NERDTreeToggle<CR> 
112 "nnoremap <Leader>o :NERDTreeFind<CR>
113 
114 let g:tagbar_type_go = { 
115     \ 'ctagstype' : 'go',
116     \ 'kinds'     : [ 
117         \ 'p:package',
118         \ 'i:imports:1',
119         \ 'c:constants',
120         \ 'v:variables',
121         \ 't:types',
122         \ 'n:interfaces',
123         \ 'w:fields',
124         \ 'e:embedded',
125         \ 'm:methods',
126         \ 'r:constructor',
127         \ 'f:functions'
128     \ ],
129     \ 'sro' : '.',
130     \ 'kind2scope' : { 
131         \ 't' : 'ctype',
132         \ 'n' : 'ntype'
133     \ },
134     \ 'scope2kind' : { 
135         \ 'ctype' : 't',
136         \ 'ntype' : 'n' 
137     \ },
138     \ 'ctagsbin'  : 'gotags',
139     \ 'ctagsargs' : '-sort -silent'
140 \ } 
141 
142 "-----tagbar-------
143 let g:tagbar_width=32
144 "let g:tagbar_autofocus=1
145 nnoremap <F6> :TagbarToggle<CR>
146 
147 "-----YouCompleteMe-----
148 let g:ycm_server_python_interpreter= '/usr/bin/python'
149 let g:ycm_python_binary_path = '/usr/bin/python'
150 let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' "默认配置文件
151 "let g:ycm_key_invoke_completion = '<C-Tab>'         "跨文件补全
152 let g:ycm_confirm_extra_conf = 0                    "关闭加载配置文件提示
153 let g:ycm_cache_omnifunc = 0                        "关闭补全缓存
154 let g:ycm_enable_diagnostic_signs = 0               "关闭诊断提示符
155 let g:ycm_enable_diagnostic_highlighting = 1        "关闭诊断高亮
156 "let g:ycm_show_diagnostics_ui = 0                   "关闭诊断ui
157 let g:ycm_min_num_of_chars_for_completion = 2       "n字符开始自动补全
161 
162 "跳转至定义或声明处
163 nnoremap <Leader>d :YcmCompleter GoToDefinitionElseDeclaration<CR>
164 "获取变量/函数类型
165 nnoremap <Leader>t :YcmCompleter GetType<CR>
166 
167 "极简风格的 ~/.ycm_extra_conf.py 文件,此处仅作助记用,以下内容不应解除注释
168 "def FlagsForFile( filename, **kwargs ):
169 "   return {
170 "     'flags': [ '-x', 'c', '-Wall', '-Wextra', '-Werror', '-std=c11', '-isystem', '/usr/include', '-I../inc' ],
171 "   }

~/.vim/colors/desert.vim

  1 " Vim color file
  2 " Maintainer:    Hans Fugal <hans@fugal.net>
  3 " Last Change:    $Date: 2003/07/24 00:57:11 $
  4 " Last Change:    $Date: 2003/07/24 00:57:11 $
  5 " URL:        http://hans.fugal.net/vim/colors/desert.vim
  6 " Version:    $Id: desert.vim,v 1.7 2003/07/24 00:57:11 fugalh Exp $
  7 
  8 " cool help screens
  9 " :he group-name
 10 " :he highlight-groups
 11 " :he cterm-colors
 12 
 13 set background=dark
 14 if version > 580
 15     " no guarantees for version 5.8 and below, but this makes it stop
 16     " complaining
 17     hi clear
 18     if exists("syntax_on")
 19     syntax reset
 20     endif
 21 endif
 22 let g:colors_name="desert"
 23 
 24 hi Normal    guifg=White guibg=grey20
 25 
 26 " highlight groups
 27 hi Cursor    guibg=indianred guifg=khaki
 28 "hi CursorIM
 29 "hi Directory
 30 "hi DiffAdd
 31 "hi DiffChange
 32 "hi DiffDelete
 33 "hi DiffText
 34 "hi ErrorMsg
 35 hi VertSplit    guibg=#c2bfa5 guifg=grey50 gui=none
 36 hi Folded    guibg=grey30 guifg=gold
 37 hi FoldColumn    guibg=grey30 guifg=tan
 38 hi IncSearch    guifg=slategrey guibg=khaki
 39 "hi LineNr
 40 hi ModeMsg    guifg=goldenrod
 41 hi MoreMsg    guifg=SeaGreen
 42 hi NonText    guifg=LightBlue guibg=grey30
 43 hi Question    guifg=springgreen
 44 hi Search    guibg=olivedrab guifg=wheat
 45 hi SpecialKey    guifg=yellowgreen
 46 hi StatusLine    guibg=#c2bfa5 guifg=black gui=none
 47 hi StatusLineNC    guibg=#c2bfa5 guifg=grey50 gui=none
 48 hi Title    guifg=indianred
 49 hi Visual    gui=none guifg=khaki guibg=olivedrab
 50 "hi VisualNOS
 51 hi WarningMsg    guifg=salmon
 52 "hi WildMenu
 53 "hi Menu
 54 "hi Scrollbar
 55 "hi Tooltip
 56 
 57 " syntax highlighting groups
 58 hi Comment    guifg=SkyBlue
 59 hi Constant    guifg=#ffa0a0
 60 hi Identifier    guifg=palegreen
 61 hi Statement    guifg=khaki
 62 hi PreProc    guifg=indianred
 63 hi Type        guifg=darkkhaki
 64 hi Special    guifg=navajowhite
 65 "hi Underlined
 66 hi Ignore    guifg=grey40
 67 "hi Error
 68 hi Todo        guifg=orangered guibg=yellow2
 69 
 70 " color terminal definitions
 71 hi SpecialKey    ctermfg=darkgreen
 72 hi NonText    cterm=bold ctermfg=darkblue
 73 hi Directory    ctermfg=darkcyan
 74 hi ErrorMsg    cterm=bold ctermfg=7 ctermbg=1
 75 hi IncSearch    cterm=NONE ctermfg=yellow ctermbg=green
 76 hi Search    cterm=NONE ctermfg=grey ctermbg=blue
 77 hi MoreMsg    ctermfg=darkgreen
 78 hi ModeMsg    cterm=NONE ctermfg=brown
 79 hi LineNr    ctermfg=3
 80 hi Question    ctermfg=green
 81 hi StatusLine    cterm=bold,reverse
 82 hi StatusLineNC cterm=reverse
 83 hi VertSplit    cterm=reverse
 84 hi Title    ctermfg=5
 85 hi Visual    cterm=reverse
 86 hi VisualNOS    cterm=bold,underline
 87 hi WarningMsg    ctermfg=1
 88 hi WildMenu    ctermfg=0 ctermbg=3
 89 hi Folded    ctermfg=darkgrey ctermbg=NONE
 90 hi FoldColumn    ctermfg=darkgrey ctermbg=NONE
 91 hi DiffAdd    ctermbg=4
 92 hi DiffChange    ctermbg=5
 93 hi DiffDelete    cterm=bold ctermfg=4 ctermbg=6
 94 hi DiffText    cterm=bold ctermbg=1
 95 hi Comment    ctermfg=darkcyan
 96 hi Constant    ctermfg=brown
 97 hi Special    ctermfg=5
 98 hi Identifier    ctermfg=6
 99 hi Statement    ctermfg=3
100 hi PreProc    ctermfg=5
101 hi Type        ctermfg=2
102 hi Underlined    cterm=underline ctermfg=5
103 hi Ignore    cterm=bold ctermfg=7
104 hi Ignore    ctermfg=darkgrey
105 hi Error    cterm=bold ctermfg=7 ctermbg=1

||

posted @ 2018-06-16 09:24  范辉  阅读(676)  评论(0编辑  收藏  举报