首页 > 学院 > 操作系统 > 正文

vim配置文件

2024-06-28 16:04:37
字体:
来源:转载
供稿:网友

预览

这里写图片描述

~/.vimrc

" basic {{set numberset rulerset showcmdset nobackupset noswapfileset cursorlineset autoindentset cindentset smarttabset expandtabset smartindentset wildmenuset hlsearchset nowrapset guifont=monacoset encoding=utf-8set mouse=aset tabstop=4set shiftwidth=4set softtabstop=4set history=1000" }}" leader {{let mapleader=","nmap <leader>w :w<CR>nmap <leader>q :q<CR>nmap <leader>q1 :q!<CR>nmap <leader>wq :wq<CR>nmap <leader>y "+ynmap <leader>p "+pnmap <space> :nmap <C-l> :noh<CR>"buffernmap <leader><Tab> :bn<CR>"strip all trailing whitespace in the current filennoremap <leader>w :%s//s/+$//<cr>:let @/=''<CR>" }}" hightlightsyntax enablesyntax on" color" airline can be display when set thisset t_Co=256set laststatus=2"set background=darkcolorscheme molokai"color molokaifiletype onfiletype indent onfiletype plugin onfiletype plugin indent on" for vundle {{set nocompatiblefiletype offset rtp+=~/.vim/bundle/Vundle.vimcall vundle#rc()" add plugin at therePlugin 'VundleVim/Vundle.vim'Plugin 'vim-airline/vim-airline'Plugin 'vim-airline/vim-airline-themes'Plugin 'scrooloose/nerdtree'Plugin 'nathanaelkane/vim-indent-guides'Plugin 'tpope/vim-fugitive'Plugin 'djoshea/vim-matlab'Plugin 'djoshea/vim-matlab-fold'Plugin 'dracula/vim'Plugin 'terryma/vim-multiple-cursors'Plugin 'kien/ctrlp.vim'Plugin 'majutsushi/tagbar'Plugin 'Valloric/YouCompleteMe'Plugin 'Raimondi/delimitMate'Plugin 'docunext/closetag.vim'Plugin 'scrooloose/nerdcommenter'Plugin 'SirVer/ultisnips'Plugin 'honza/vim-snippets'Plugin 'scrooloose/syntastic'" Plugin 'jeaye/color_coded'Bundle 'ShowTrailingWhitespace'Bundle 'molokai'" plugin end herecall vundle#end()filetype plugin indent on" }}" settings for airlinelet g:airline_theme='luna'let g:airline_powerline_fonts=1let g:solarized_termcolors=16let g:airline#extensions#tabline#enabled = 1let g:airline#extensions#tagbar#enabled = 1let g:airline#extensions#syntastic#enabled = 1let g:airline#extensions#tabline#buffer_idx_mode = 1" tarbarnmap <leader>tb :Tagbar<CR>" settings for nerdtreemap <C-b> :NERDTreeToggle<CR>autocmd StdinReadPRe * let s:std_in=1autocmd StdinReadPre * let s:std_in=1autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endiflet g:NERDTreeDirArrowExpandable = '▸'let g:NERDTreeDirArrowCollapsible = '▾'" settings for IndentGuideslet g:indent_guides_enable_on_vim_startup = 1let g:indent_guides_auto_colors = 0let g:indent_guides_guide_size = 1autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4hi IndentGuidesOdd guibg=red ctermbg=3hi IndentGuidesEven guibg=green ctermbg=4" settings for youcompleteme" highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5" highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'set completeopt=longest,menu "让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口inoremap <expr> <CR> pumvisible() ? "/<C-y>" : "/<CR>" "回车即选中当前项" youcompleteme 默认tab s-tab 和自动补全冲突let g:ycm_key_list_select_completion=['<c-n>']" let g:ycm_key_list_select_completion = ['Down']let g:ycm_key_list_previous_completion=['<c-p>']" let g:ycm_key_list_previous_completion = ['<Up>']let g:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示let g:ycm_key_invoke_completion = '<C-a>' " 强制补全let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 基于标签引擎let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项let g:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都重新生成匹配项let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "force recomile with syntastic" nnoremap <leader>lo :lopen<CR> "open locationlist" nnoremap <leader>lc :lclose<CR> "close locationlistinoremap <leader><leader> <C-x><C-o>let g:ycm_complete_in_comments = 1let g:ycm_complete_in_strings = 1let g:ycm_collect_identifiers_from_comments_and_strings = 0nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处" imap { {}<ESC>i<CR><ESC>V<O" settings for nerdcommenter" Add spaces after comment delimiters by defaultlet g:NERDSpaceDelims = 1" Use compact syntax for prettified multi-line commentslet g:NERDCompactSexyComs = 1" Align line-wise comment delimiters flush left instead of following code indentationlet g:NERDDefaultAlign = 'left'" Set a language to use its alternate delimiters by defaultlet g:NERDAltDelims_java = 1" Add your own custom formats or override the defaultslet g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }" Allow commenting and inverting empty lines (useful when commenting a region)let g:NERDCommentEmptyLines = 1" Enable trimming of trailing whitespace when uncommentinglet g:NERDTrimTrailingWhitespace = 1" for ultisnipslet g:UltiSnipsExpandTrigger="<tab>"let g:UltiSnipsJumpForwardTrigger="<c-b>"let g:UltiSnipsJumpBackwardTrigger="<c-z>"" syntasticlet g:syntastic_error_symbol = '✗'let g:syntastic_warning_symbol = '⚠'" color code" hi link StructDecl Type" hi link UnionDecl Type" hi link ClassDecl Type" hi link EnumDecl Type

youcompleteme配置文件

# Copyright (C) 2014 Google Inc.## This file is part of ycmd.## ycmd is free software: you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation, either version 3 of the License, or# (at your option) any later version.## ycmd is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with ycmd. If not, see <http://www.gnu.org/licenses/>.import osimport ycm_core# These are the compilation flags that will be used in case there's no# compilation database set (by default, one is not set).# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.flags = ['-Wall','-Wextra','-Werror','-fexceptions','-DNDEBUG',# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which# language to use when compiling headers. So it will guess. Badly. So C++# headers will be compiled as C headers. You don't want that so ALWAYS specify# a "-std=<something>".# For a C project, you would set this to something like 'c99' instead of# 'c++11'.'-std=c++11',# ...and the same thing goes for the magic -x option which specifies the# language that the files to be compiled are written in. This is mostly# relevant for c++ headers.# For a C project, you would set this to 'c' instead of 'c++'.'-x','c++','-isystem','/usr/include','-isystem','/usr/local/include','-isystem','/applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1','-isystem','/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include',# 注意下面把的库文件根据你的系统修改# 格式和下面类似一个'-isystem'一个库地址'-isystem','/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1','-isystem','/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1/x86_64-pc-linux-gnu','-isystem','/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1/backward','-isystem','/usr/local/include','-isystem','/usr/bin/../lib/clang/3.9.1/include','-isystem','/usr/include',]# Set this to the absolute path to the folder (NOT the file!) containing the# compile_commands.json file to use that instead of 'flags'. See here for# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html## Most projects will NOT need to set this to anything; you can just change the# 'flags' list of compilation flags.compilation_database_folder = ''if os.path.exists( compilation_database_folder ): database = ycm_core.CompilationDatabase( compilation_database_folder )else: database = NoneSOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]def DirectoryOfThisScript(): return os.path.dirname( os.path.abspath( __file__ ) )def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): if not working_directory: return list( flags ) new_flags = [] make_next_absolute = False path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] for flag in flags: new_flag = flag if make_next_absolute: make_next_absolute = False if not flag.startswith( '/' ): new_flag = os.path.join( working_directory, flag ) for path_flag in path_flags: if flag == path_flag: make_next_absolute = True break if flag.startswith( path_flag ): path = flag[ len( path_flag ): ] new_flag = path_flag + os.path.join( working_directory, path ) break if new_flag: new_flags.append( new_flag ) return new_flagsdef IsHeaderFile( filename ): extension = os.path.splitext( filename )[ 1 ] return extension in [ '.h', '.hxx', '.hpp', '.hh' ]def GetCompilationInfoForFile( filename ): # The compilation_commands.json file generated by CMake does not have entries # for header files. So we do our best by asking the db for flags for a # corresponding source file, if any. If one exists, the flags for that file # should be good enough. if IsHeaderFile( filename ): basename = os.path.splitext( filename )[ 0 ] for extension in SOURCE_EXTENSIONS: replacement_file = basename + extension if os.path.exists( replacement_file ): compilation_info = database.GetCompilationInfoForFile( replacement_file ) if compilation_info.compiler_flags_: return compilation_info return None return database.GetCompilationInfoForFile( filename )# This is the entry point; this function is called by ycmd to produce flags for# a file.def FlagsForFile( filename, **kwargs ): if database: # Bear in mind that compilation_info.compiler_flags_ does NOT return a # python list, but a "list-like" StringVec object compilation_info = GetCompilationInfoForFile( filename ) if not compilation_info: return None final_flags = MakeRelativePathsInFlagsAbsolute( compilation_info.compiler_flags_, compilation_info.compiler_working_dir_ ) else: relative_to = DirectoryOfThisScript() final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) return { 'flags': final_flags }

安装命令如下

# 首先安装cmake和clang # 把上面的vimrc复制到你的vimrc # 编辑.ycm_extra_conf.py到$HOME/ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim # 第一次进入会因为找不到mololai而报错,忽略即可 vim +PluginInstall +qall cp -r $HOME/.vim/bundle/molokai/colors ../../ $HOME/.vim/bundle/YouCompleteMe/install.sh --clang-completer --system-libclang
上一篇:awk总结

下一篇:linux 分区理解

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表