标签:
要说Linux下比较好用的文本编辑器,我推荐vim(当然很多人都用emace,可我没用过),用vim也有一年左右,有些心得体会想与诸位分享。在我的学习过程中,借鉴了不少优秀的博客,其中有csdn大神namecyf的博客http://blog.csdn.net/namecyf/article/details/7787479和博客园风歌的blog的http://www.cnblogs.com/junnyfeng/p/3633697.html这两篇文章。
•安装
Archlinux下安装Vim直接用pacman即可,其他Linux系统也类似,建议把gvim也安装上。
•配置文件
系统安装vim时应该会有一个vimrc文件,修改里面的代码可以对所有用户的Vim进行配置,我们一般只是对当前用户的vim进行配置,故我们可以在$HOME下创建一个.vimrc的隐藏文件,这个就是vim的配置文件。
•查看vim是否支持python
1.在vim界面执行:version,如果python前有+号,就是支持,减号就是不支持。如果不支持,则需要以编译安装方式重新安装vim。如下:
2.首先把系统的vim全部删除,包括vim,gvim,vim-runtime,vim-common,vim-gui-common,vim-tiny
3.然后下载源码包
4.进入目录进行配置编译属性,如下
cd ./vim74/src
./configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontset
5.编译
make && make install
•安装vundle插件
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
以后只需要在.vimrc中添加插件,然后咋爱vim界面运行:BundleInstall就可以安装相应插件。
•使用help命令
在vim执行:help <subject>就可以查看subject的相关解释,可以获得你想象得到的帮助:
(1)查找关于某个字母的命令 :help x 查找关于x的命令
(2)得到所以命令的索引:help index
(3)带有控制键的命令 :help CTRL-A 注意大写
(4)带有模式的命令:help i-CTRL-A 在虚拟模式下 v-CTRL-A 在冒号模式 c-CTRL-A
(5)带有命令行参数 :help -t
(6)关于某个选项的如:help ‘number‘
(7) 特殊按键用尖括号:help i-<Up>
(8)可以用错误ID号来寻求帮助 :help E37
(9)关于引发自动命令的事件“Eventname”的帮助:help Eventname
(10)关于编译时特性“+subject”的帮助:help +subject
(11)关于函数的subject()的帮助:help subject()
(12)到帮助文件digraphs.txt文件的开头:help digraphos.txt
(13)查找一个以“pattern”开始的帮助标记:help pattern<Tab>
(14)下一个匹配项:cn
(15)前一个匹配项:cN或:cprev
(16)第一个/最后一个匹配项:cfirst/clast
(17)打开/关闭快速修改窗口:copen/cclose
这部分主要将一些比较实用的插件以及它在.vimrc里如何配置。
tags文件是由ctags程序产生的一个索引文件, ctags程序其是叫"Exuberant Ctags", 是Unix上面ctags程序的替代品, 并且比它功能强大, 是大多数Linux发行版上默认的ctags程序. 那么tags文件是做什么用的呢? 如果你在读程序时看了一个函数调用, 或者一个变量, 或者一个宏等等, 你想知道它们的定义在哪儿, 怎么办呢? 用grep? 那会搜出很多不相干的地方. 现在流行用是的<C-]>, 谁用谁知道呀, 当光标在某个函数或变量上时, 按下"Ctrl+]", 光标会自动跳转到其定义处,再按"Ctrl+T"就会跳回原来位置,够厉害吧!
下面我们就来安装吧!
•首先现在这个网站上下载ctags的压缩文件(类似ctags-x.x.tar.gz的文件):http://ctags.sourceforge.net
•然后就是解压安装了:
#tar -xzvf ctags-x.x.tar.gz --x自行替换
#cd ctags-x.x
#make && make install
这样Ctags就安装好了,执行#ctags -R就可以递归地生成当前目录下的tags文件了。现在进行一些配置:
在.vimrc中加入以下内容:
set tags=./tags,./../tags,./*/tags --这样的设置可以生成当前目录,上级目录以及当前目录的所有子目录的tags文件
然后绑定快捷键F7就可以,在vim界面下也可以生成tags文件
map <F7> <Esc>:!ctags -R <CR><CR>
tagbar是一个taglist的替代品,比taglist更适合c++使用,函数能够按类区分,支持按类折叠显示等,显示结果清晰简洁。
安装TagBar只需要在.vimrc中添加:
Plugin ‘majutsushi/tagbar‘
然后在vim界面中输入:BundleInstall即可,可用vundle进行管理。
我在自己的vim里绑定了一个快捷键"tb",可以打开TagBar:
map tb <Esc>:Tagbar <CR>
:help tagbar可查阅详细用法。
右边的则是tagbar
无意中看到朋友使用的vim竟然能在左边显示树形目录,感觉很方便,这样子文件夹有什么文件一目了然。打听后是一个叫做NERDTree的插件,这个插件在vundle居然也有,于是可以这样安装:
Plugin ‘scrooloose/nerdtree‘
同样的在vim界面中:BundleInstall进行安装
我的设置是F8打开:
map <F8> <Esc>:NERDTree <CR>
:help nerdtree可查阅详细用法
左边的为nerdtree
PowerLine是一个增强的Vim状态栏插件。当Vim处于NORMAL、INSERT、BLOCK等状态时,状态栏会呈现不同的颜色,同时状态栏还会显示当前编辑文件的格式(uft-8等)、文件类型(java、xml等)和光标位置等。同样的vundle里也有
Plugin ‘Lokaltog/vim-powerline‘
然后安装同上,无需设置,重启即可看到效果。
以上图片的下面部分则是powerline的效果图:
我用的背景和文字分别是:molokai和Source Code Pro
当然了,需要安装对应的字体和下载主题文件,主题文件需要移至$HOME/.vim/colors/目录下,字体文件移至/usr/share/fonts/目录下(建议将.ttf文件移至TTF目录下,.otf文件移至OTF目录下),然后更新系统的字体缓存:#fc-cache -fv即可。
配置字体和背景还需要:
colorscheme molokai
set guifont=Source\ Code\ Pro\ 12 #12是字体大小
字体以及主题文件的下载地址我都会在下面给出,接下来介绍jeaye/color_coded插件:
这个插件可以高亮c/c++程序的struct,class等等结构。不过要在.vimrc中配置:
hi link StructDecl Type
hi link UnionDecl Type
hi link ClassDecl Type
hi link EnumDecl Type
安装这个插件要求vim支持python2.6以上,如果支持,则用Vundle安装:
Plugin ‘Valloric/YouCompleteMe‘
之后的安装同上,安装完成后会有一个错误显示:
Done! With errors; press l to view log
ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need
to compile YCM before using it. Read the docs!
这是正常的,因为ycm需要手工编译出库文件,到 .vim/bundle/YouCompleteMe下跑
#./install.sh --clang-completer --参数是为了支持c/c++ 的补全,系统需要安装clang
YouCompleteMe 的补全配置文件在$HOME/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py(我的在$HOME/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py),这是个隐藏文件。通过修改它可以进行自己想要的补全功能。
我的.ycm_extra_conf.py文件配置如下:
1 # This file is NOT licensed under the GPLv3, which is the license for the rest 2 # of YouCompleteMe. 3 # 4 # Here‘s the license text for this file: 5 # 6 # This is free and unencumbered software released into the public domain. 7 # 8 # Anyone is free to copy, modify, publish, use, compile, sell, or 9 # distribute this software, either in source code form or as a compiled 10 # binary, for any purpose, commercial or non-commercial, and by any 11 # means. 12 # 13 # In jurisdictions that recognize copyright laws, the author or authors 14 # of this software dedicate any and all copyright interest in the 15 # software to the public domain. We make this dedication for the benefit 16 # of the public at large and to the detriment of our heirs and 17 # successors. We intend this dedication to be an overt act of 18 # relinquishment in perpetuity of all present and future rights to this 19 # software under copyright law. 20 # 21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 # OTHER DEALINGS IN THE SOFTWARE. 28 # 29 # For more information, please refer to <http://unlicense.org/> 30 31 import os 32 import ycm_core 33 34 # These are the compilation flags that will be used in case there‘s no 35 # compilation database set (by default, one is not set). 36 # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. 37 flags = [ 38 ‘-Wall‘, 39 ‘-Wextra‘, 40 ‘-Werror‘, 41 ‘-Wc++98-compat‘, 42 ‘-Wno-long-long‘, 43 ‘-Wno-variadic-macros‘, 44 ‘-fexceptions‘, 45 ‘-DNDEBUG‘, 46 # You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM 47 # source code needs it. 48 ‘-DUSE_CLANG_COMPLETER‘, 49 # THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won‘t know which 50 # language to use when compiling headers. So it will guess. Badly. So C++ 51 # headers will be compiled as C headers. You don‘t want that so ALWAYS specify 52 # a "-std=<something>". 53 # For a C project, you would set this to something like ‘c99‘ instead of 54 # ‘c++11‘. 55 ‘-std=c++11‘, 56 # ...and the same thing goes for the magic -x option which specifies the 57 # language that the files to be compiled are written in. This is mostly 58 # relevant for c++ headers. 59 # For a C project, you would set this to ‘c‘ instead of ‘c++‘. 60 ‘-x‘, 61 ‘c++‘, 62 ‘-isystem‘, 63 ‘../BoostParts‘, 64 ‘-isystem‘, 65 # This path will only work on OS X, but extra paths that don‘t exist are not 66 # harmful 67 ‘-isystem‘, 68 ‘../llvm/include‘, 69 ‘-isystem‘, 70 ‘../llvm/tools/clang/include‘, 71 ‘-I‘, 72 ‘.‘, 73 ‘-I‘, 74 ‘./ClangCompleter‘, 75 ‘-isystem‘, 76 ‘./tests/gmock/gtest‘, 77 ‘-isystem‘, 78 ‘./tests/gmock/gtest/include‘, 79 ‘-isystem‘, 80 ‘./tests/gmock‘, 81 ‘-isystem‘, 82 ‘./tests/gmock/include‘, 83 ‘-isystem‘, 84 ‘/usr/bin/‘, 85 ‘-isystem‘, 86 ‘/usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1‘, 87 ‘-isystem‘, 88 ‘/usr/include/c++/6.1.1‘, 89 ‘-isystem‘, 90 ‘/usr/include/c++/6.1.1/x86_64-pc-linux-gnu‘, 91 ‘-isystem‘, 92 ‘/usr/include/c++/6.1.1/backward‘, 93 ‘-isystem‘, 94 ‘/usr/local/include‘, 95 ‘-isystem‘, 96 ‘/usr/lib/clang/3.8.0/include‘, 97 ‘-isystem‘, 98 ‘/usr/include‘, 99 ] 100 101 102 # Set this to the absolute path to the folder (NOT the file!) containing the 103 # compile_commands.json file to use that instead of ‘flags‘. See here for 104 # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html 105 # 106 # You can get CMake to generate this file for you by adding: 107 # set( CMAKE_EXPORT_COMPILE_COMMANDS 1 ) 108 # to your CMakeLists.txt file. 109 # 110 # Most projects will NOT need to set this to anything; you can just change the 111 # ‘flags‘ list of compilation flags. Notice that YCM itself uses that approach. 112 compilation_database_folder = ‘‘ 113 114 if os.path.exists( compilation_database_folder ): 115 database = ycm_core.CompilationDatabase( compilation_database_folder ) 116 else: 117 database = None 118 119 SOURCE_EXTENSIONS = [ ‘.cpp‘, ‘.cxx‘, ‘.cc‘, ‘.c‘, ‘.m‘, ‘.mm‘ ] 120 121 def DirectoryOfThisScript(): 122 return os.path.dirname( os.path.abspath( __file__ ) ) 123 124 125 def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): 126 if not working_directory: 127 return list( flags ) 128 new_flags = [] 129 make_next_absolute = False 130 path_flags = [ ‘-isystem‘, ‘-I‘, ‘-iquote‘, ‘--sysroot=‘ ] 131 for flag in flags: 132 new_flag = flag 133 134 if make_next_absolute: 135 make_next_absolute = False 136 if not flag.startswith( ‘/‘ ): 137 new_flag = os.path.join( working_directory, flag ) 138 139 for path_flag in path_flags: 140 if flag == path_flag: 141 make_next_absolute = True 142 break 143 144 if flag.startswith( path_flag ): 145 path = flag[ len( path_flag ): ] 146 new_flag = path_flag + os.path.join( working_directory, path ) 147 break 148 149 if new_flag: 150 new_flags.append( new_flag ) 151 return new_flags 152 153 154 def IsHeaderFile( filename ): 155 extension = os.path.splitext( filename )[ 1 ] 156 return extension in [ ‘.h‘, ‘.hxx‘, ‘.hpp‘, ‘.hh‘ ] 157 158 159 def GetCompilationInfoForFile( filename ): 160 # The compilation_commands.json file generated by CMake does not have entries 161 # for header files. So we do our best by asking the db for flags for a 162 # corresponding source file, if any. If one exists, the flags for that file 163 # should be good enough. 164 if IsHeaderFile( filename ): 165 basename = os.path.splitext( filename )[ 0 ] 166 for extension in SOURCE_EXTENSIONS: 167 replacement_file = basename + extension 168 if os.path.exists( replacement_file ): 169 compilation_info = database.GetCompilationInfoForFile( 170 replacement_file ) 171 if compilation_info.compiler_flags_: 172 return compilation_info 173 return None 174 return database.GetCompilationInfoForFile( filename ) 175 176 177 def FlagsForFile( filename, **kwargs ): 178 if database: 179 # Bear in mind that compilation_info.compiler_flags_ does NOT return a 180 # python list, but a "list-like" StringVec object 181 compilation_info = GetCompilationInfoForFile( filename ) 182 if not compilation_info: 183 return None 184 185 final_flags = MakeRelativePathsInFlagsAbsolute( 186 compilation_info.compiler_flags_, 187 compilation_info.compiler_working_dir_ ) 188 189 # NOTE: This is just for YouCompleteMe; it‘s highly likely that your project 190 # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR 191 # ycm_extra_conf IF YOU‘RE NOT 100% SURE YOU NEED IT. 192 # try: 193 # final_flags.remove( ‘-stdlib=libc++‘ ) 194 # except ValueError: 195 # pass 196 else: 197 relative_to = DirectoryOfThisScript() 198 final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) 199 200 return { 201 ‘flags‘: final_flags, 202 ‘do_cache‘: True 203 }
flags里面的这几条请依据自己的gcc和clang的版本来填写(gcc --version和clang --version):
‘/usr/lib64/gcc/x86_64-pc-linux-gnu/6.1.1‘,
‘/usr/include/c++/6.1.1‘,
‘/usr/include/c++/6.1.1/x86_64-pc-linux-gnu‘,
‘/usr/include/c++/6.1.1/backward‘,
‘/usr/lib/clang/3.8.0/include‘
接着就是在.vimrc文件里进行配置了:
""""""""""""" ycm配置 nnoremap <leader>gt :YcmCompleter GetType<CR> nnoremap <leader>gp :YcmCompleter GetParent<CR> nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR> let g:ycm_global_ycm_extra_conf = ‘~/.ycm_extra_conf.py‘ let g:ycm_confirm_extra_conf=0 "不再询问是否加载.ycm_extra_conf.py文件 let g:ycm_complete_in_comments = 1 "注释也用补全 let g:ycm_autoclose_preview_window_after_completion = 1 let g:ycm_add_preview_to_completeopt = 0
gt可以获得该变量类型,gp可以跳转到它的父类的声明处,gg跳转到定义处。详细教程参考https://github.com/Valloric/YouCompleteMe/#options。
这个功能主要使用自动命令autocmd,使得vim自动识别文件,然后F5进行编译,F6运行程序,另外还有整行注释功能(按./注释,按..取消注释):
""""""""""""""""""""""""""""""""""""""""C语言的编译运行""""""""""""""""""""""""""""""""""""""""" " <F5>编译C/py语言,<F6>运行 augroup ccompile autocmd Filetype c map <F5> <Esc>:w<CR>:!gcc % -std=c99 -g -o %< -lm <CR> autocmd Filetype cpp map <F5> <Esc>:w<CR>:!g++ % -std=c++11 -g -o %< -lm <CR> autocmd Filetype python map <F5> <Esc>:w<CR>:!python % <CR> augroup END augroup crun autocmd Filetype c map <F6> <Esc>:! ./%< <CR> autocmd Filetype cpp map <F6> <Esc>:! ./%< <CR> augroup END " 整行注释 augroup comment autocmd Filetype c noremap <buffer> <localleader>/ I//<Esc> autocmd Filetype cpp noremap <buffer> <localleader>/ I//<Esc> autocmd Filetype h noremap <buffer> <localleader>/ I//<Esc> augroup END augroup nocomment autocmd Filetype c noremap <buffer> <localleader>. ^xx autocmd Filetype cpp noremap <buffer> <localleader>. ^xx autocmd Filetype h noremap <buffer> <localleader>. ^xx augroup END
•.vimrc文件:click here
•Source Code Pro字体:click here
•主题(这里有百来个,自己挑选):click here
以下是我的.vimrc文件内容:
1 "Y_VIMRC 2 "author cqm 3 "email chester@hit.edu.cn 4 "Time: Wed Feb 3 16:40:07 CST 2016 5 "settings are as followed: 6 7 "---------------------------------START------------------------------------------------- 8 9 10 """""""""""""""""""""""""""""""""""""""基本设置"""""""""""""""""""""""""""""""""""""""" 11 " 设定默认解码 12 set fenc=utf-8 13 set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 14 15 " 支持256色,使得vim配色支持终端 16 set t_Co=256 17 18 " C缩进 19 set smartindent 20 set cindent 21 22 " 设置背景和字体 23 colorscheme molokai 24 set guifont=Source\ Code\ Pro\ 12 25 26 " 不要使用vi的键盘模式,而是vim自己的 27 set nocompatible 28 29 " history文件中需要记录的行数 30 set history=1000 31 32 " 在处理未保存或只读文件的时候,弹出确认 33 set confirm 34 35 " 与windows共享剪贴板 36 set clipboard+=unnamed 37 38 " 侦测文件类型 39 filetype off 40 41 " 为特定文件类型载入相关缩进文件 42 filetype indent on 43 44 " 带有如下符号的单词不要被换行分割 45 set iskeyword+=_,$,@,%,#,- 46 47 " 语法高亮 48 syntax enable 49 syntax on 50 51 "隐藏GUI的工具栏 52 set guioptions=P 53 54 " 不要备份文件 55 set nobackup 56 57 " 不要生成swap文件 58 setlocal noswapfile 59 60 " 字符间插入的像素行数目 61 set linespace=0 62 63 " 在状态行上显示光标所在位置的行号和列号 64 set ruler 65 66 " 命令行(在状态行下)的高度,默认为1,这里是2 67 set cmdheight=2 68 69 " 使回格键(backspace)正常处理indent, eol, start等 70 set backspace=indent,eol,start 71 72 " 允许backspace和光标键跨越行边界 73 set whichwrap+=<,>,b,s,[,] 74 75 " 不让vim发出讨厌的滴滴声 76 set noerrorbells 77 78 " 高亮显示匹配的括号 79 set showmatch 80 81 " 匹配括号高亮的时间(单位是十分之一秒) 82 set matchtime=5 83 84 " 在搜索的时候忽略大小写 85 set ignorecase 86 87 " 不要高亮被搜索的句子(phrases) 88 set nohlsearch 89 90 " 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索) 91 set incsearch 92 93 " 光标移动到buffer的顶部和底部时保持3行距离,窗口滚动最小距离 94 set scrolloff=3 95 96 " 2为总显示最后一个窗口的状态行 97 " 设为1则窗口数多于一个的时候显示最后一个窗口的状态行; 98 " 0不显示最后一个窗口的状态行 99 set laststatus=2 100 101 " 继承前一行的缩进方式,特别适用于多行注释 102 ""set autoindent 103 104 " 显示行号 105 set number 106 107 " 制表符为4 108 set tabstop=4 109 110 " 统一缩进为4 111 set softtabstop=4 112 set shiftwidth=4 113 114 " 不要用空格代替制表符 115 set noexpandtab 116 117 " 不要换行 118 " set nowrap 119 " set sidescroll=10 120 121 " 在行和段开始处使用制表符 122 set smarttab 123 124 " Ctrl+A全选,Ctrl+C复制,Ctrl+V粘贴 125 map <C-A> ggvG$ 126 imap <C-A> <Esc>ggvG$ 127 vmap <C-C> "+y<Esc> 128 map <C-V> "+p 129 imap <C-V> <Esc>"+pa 130 131 " 括号等的自动匹配 132 inoremap ( ()<Esc>i 133 inoremap [ []<Esc>i 134 inoremap { {}<Esc>i 135 inoremap ‘ ‘‘<Esc>i 136 inoremap " ""<Esc>i 137 138 " 设置<leader>和<localleader> 139 let mapleader = "," 140 let maplocalleader = "." 141 142 " 可以折叠 143 set foldenable 144 set foldmethod=manual 145 146 " 自动更新.vimrc 147 map <leader>vo <Esc>:vsp ~/.vimrc<CR> 148 149 150 """"""""""""""""""""""""""""""""""""""""Vundle管理插件"""""""""""""""""""""""""""""""""""""""" 151 set rtp+=~/.vim/bundle/vundle/ 152 call vundle#rc() 153 Plugin ‘gmarik/vundle‘ 154 Plugin ‘tpope/vim-fugitive‘ 155 Plugin ‘Lokaltog/vim-easymotion‘ 156 Plugin ‘tpope/vim-rails.git‘ 157 Plugin ‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘} 158 Plugin ‘L9‘ 159 Plugin ‘FuzzyFinder‘ 160 Plugin ‘git://git.wincent.com/command-t.git‘ 161 Plugin ‘Valloric/YouCompleteMe‘ 162 Plugin ‘Valloric/ListToggle‘ 163 Plugin ‘scrooloose/syntastic‘ 164 Plugin ‘davidhalter/jedi‘ 165 Plugin ‘majutsushi/tagbar‘ 166 Plugin ‘scrooloose/nerdtree‘ 167 Plugin ‘Lokaltog/vim-powerline‘ 168 Plugin ‘jeaye/color_coded‘ 169 Plugin ‘octol/vim-cpp-enhanced-highlight‘ 170 171 call vundle#end() 172 filetype plugin indent on " required 173 174 """"""""""""""""""""""""""""""""""""""""C语言的编译运行""""""""""""""""""""""""""""""""""""""""" 175 " <F5>编译C/py语言,<F6>运行 176 augroup ccompile 177 autocmd Filetype c map <F5> <Esc>:w<CR>:!gcc % -std=c99 -g -o %< -lm <CR> 178 autocmd Filetype cpp map <F5> <Esc>:w<CR>:!g++ % -std=c++11 -g -o %< -lm <CR> 179 autocmd Filetype python map <F5> <Esc>:w<CR>:!python % <CR> 180 augroup END 181 182 augroup crun 183 autocmd Filetype c map <F6> <Esc>:! ./%< <CR> 184 autocmd Filetype cpp map <F6> <Esc>:! ./%< <CR> 185 augroup END 186 187 " 整行注释 188 augroup comment 189 autocmd Filetype c noremap <buffer> <localleader>/ I//<Esc> 190 autocmd Filetype cpp noremap <buffer> <localleader>/ I//<Esc> 191 autocmd Filetype h noremap <buffer> <localleader>/ I//<Esc> 192 augroup END 193 194 augroup nocomment 195 autocmd Filetype c noremap <buffer> <localleader>. ^xx 196 autocmd Filetype cpp noremap <buffer> <localleader>. ^xx 197 autocmd Filetype h noremap <buffer> <localleader>. ^xx 198 augroup END 199 200 201 " 大括号补全 202 autocmd Filetype c,cpp,h inoremap {<CR> {<CR>}<Esc>O 203 204 205 206 """"""""""""""""""""""""""""""""""""""""""各插件的配置"""""""""""""""""""""""""""""""""""""""""" 207 """"""""""""" Ctags配置 208 set tags=./tags,./../tags,./*/tags 209 map <F7> <Esc>:!ctags -R <CR><CR> 210 211 """"""""""""" ycm配置 212 nnoremap <leader>gt :YcmCompleter GetType<CR> 213 nnoremap <leader>gp :YcmCompleter GetParent<CR> 214 nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR> 215 let g:ycm_global_ycm_extra_conf = ‘~/.ycm_extra_conf.py‘ 216 let g:ycm_confirm_extra_conf=0 "不再询问是否加载.ycm_extra_conf.py文件 217 let g:ycm_complete_in_comments = 1 "注释也用补全 218 let g:ycm_autoclose_preview_window_after_completion = 1 219 let g:ycm_add_preview_to_completeopt = 0 220 221 """"""""""""" TagBar设置 222 map tb <Esc>:Tagbar <CR> 223 224 """"""""""""" NerdTree设置 225 map <F8> <Esc>:NERDTree <CR> 226 227 """"""""""""" color_coded设置 228 hi link StructDecl Type 229 hi link UnionDecl Type 230 hi link ClassDecl Type 231 hi link EnumDecl Type 232 233 "----------------------------------------------END--------------------------------------------"
标签:
原文地址:http://www.cnblogs.com/vachester/p/5659648.html