鱼C论坛

 找回密码
 立即注册
查看: 2525|回复: 2

[已解决]求助一个大佬的vimrc文件,自己被改得一塌糊涂,不想用了!

[复制链接]
发表于 2019-9-10 11:51:08 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
大佬!!!!!求助一个大佬的vimrc文件,自己被改得一塌糊涂,不想用了!
最佳答案
2019-9-10 13:06:47
^_^

  1. set number                " 显示行号
  2. set laststatus=2        " 总是显示状态栏
  3. set cursorline                " 高亮显示当前行
  4. set scrolloff=3                " 光标移动到buffer的顶部和底部时保持3行距离
  5. set nowrap                " 禁止折行
  6. set ruler                " 显示光标当前位置
  7. set hlsearch                " 高亮显示搜索结果
  8. set incsearch                " 开启实时搜索
  9. set ignorecase                " 搜索时大小写不敏感
  10. set nocompatible        " 关闭兼容模式
  11. set wildmenu                " vim自身命令行模式智能补全
  12. set noshowmatch                " 不要高亮匹配括号

  13. " 缩进
  14. set tabstop=8
  15. set softtabstop=8
  16. set shiftwidth=8
  17. set noexpandtab
  18. set cindent
  19. set smartindent
  20. set autoindent

  21. let g:python_recommended_style="0"        " 关闭Python的tab

  22. " 关键字高亮
  23. syntax on

  24. " 定义快捷键的前缀,即<Leader>
  25. let mapleader=";"

  26. " 编码格式
  27. set encoding=utf-8
  28. set fileencodings=utf-8,default,gb18030,gbk,gb2312

  29. " 禁止生成临时文件
  30. set nobackup
  31. set noswapfile

  32. " 折叠
  33. set foldmethod=indent        " 缩进折叠
  34. set foldlevel=99        " 启动vim默认不折叠

  35. " 添加C语言标识符文件
  36. set tags+=~/.vim/dict/c.dict

  37. " 设置快捷键将文本复制至系统剪贴板
  38. vnoremap <Leader>y "+y        " 复制选中文本

  39. " 设置快捷键将系统剪贴板内容粘贴至vim
  40. nmap <Leader>p "+p
  41. nmap <Leader>P "+P

  42. " 自动跳到上一次的光标位置
  43. au BufReadPost * if line("'"") > 1 && line("'"") <= line("$") | exe "normal! g'"" | endif

  44. " vundle 环境
  45. set rtp+=~/.vim/bundle/Vundle.vim
  46. "set rtp+=~/Vundle.vim
  47. filetype off                        " required
  48. set nocompatible                " required

  49. call vundle#begin()
  50. Plugin 'gmarik/Vundle.vim'                                " 自己
  51. Plugin 'asins/vimcdoc'                                        " 中文帮助
  52. Plugin 'tomasr/molokai'                                        " 主题
  53. Plugin 'Lokaltog/vim-powerline'                                " 状态栏
  54. Plugin 'scrooloose/nerdcommenter'                        " 快速开关注释
  55. Plugin 'Lokaltog/vim-easymotion'                        " 快速移动光标
  56. Plugin 'mbbill/undotree'                                " 支持分支的undo
  57. Plugin 'octol/vim-cpp-enhanced-highlight'                " 额外的C++语法高亮
  58. Plugin 'majutsushi/tagbar'                                " 基于标签的标识符列表插件
  59. Plugin 'dyng/ctrlsf.vim'                                " 全局文本搜索的插件
  60. Plugin 'terryma/vim-multiple-cursors'                        " 多光标编辑插件

  61. " C/C++补全
  62. Plugin 'SirVer/ultisnips'
  63. Plugin 'honza/vim-snippets'

  64. Plugin 'davidhalter/jedi-vim'                                " Python补全

  65. Plugin 'Valloric/YouCompleteMe'                                " YCM
  66. call vundle#end()
  67. filetype plugin indent on        " required

  68. " 主题
  69. colorscheme ron
  70. "colorscheme molokai

  71. " 将开启tagbar的快捷键设置为<Leader>tb
  72. nmap <Leader>tb :TagbarToggle<CR>
  73. " 设置 tagbar 子窗口的位置出现在主编辑区的左边
  74. let tagbar_left=1
  75. " 设置标签子窗口的宽度
  76. let tagbar_width=32
  77. " tagbar 子窗口中不显示冗余帮助信息
  78. let g:tagbar_compact=1

  79. " 全局文本搜索的插件
  80. nnoremap <Leader>sp :CtrlSF<CR>

  81. " C/C++补全快捷键
  82. let g:UltiSnipsExpandTrigger="<Leader><TAB>"
  83. let g:UltiSnipsJumpForwardTrigger="<Leader><TAB>"
  84. let g:UltiSnipsJumpBackwardTrigger="<Leader><S-TAB>"

  85. " Python补全
  86. let g:jedi#completions_command=""
  87. let g:jedi#goto_assignments_command=""
  88. let g:jedi#goto_definitions_command=""
  89. let g:jedi#goto_command=""
  90. let g:jedi#rename_command="<Leader>r"
  91. let g:jedi#show_call_signatures="0"
  92. let g:jedi#popup_select_first="0"

  93. " YCM
  94. autocmd FileType cpp :let g:ycm_global_ycm_extra_conf='~/.vim/ycm_extra_conf/ycm_extra_conf_cpp.py'
  95. autocmd FileType c :let g:ycm_global_ycm_extra_conf='~/.vim/ycm_extra_conf/ycm_extra_conf_c.py'
  96. let g:ycm_server_python_interpreter='/usr/bin/python2'
  97. let g:ycm_confirm_extra_conf=0                                                " 载入ycm_extra_conf文件,是否提示确认 默认 1
  98. let g:ycm_always_populate_location_list=1                                " 是否显示自动补全诊断location list,默认 0
  99. let g:ycm_seed_identifiers_with_syntax=1                                " 语法关键字补全,默认 0
  100. let g:ycm_min_num_of_chars_for_completion=1                                " 开启自动补全输入的最少字符数,默认 2
  101. let g:ycm_complete_in_comments=1                                        " 在注释中实现自动补全,默认 0
  102. let g:ycm_error_symbol='&#10007;'                                                " 警告符号
  103. let g:ycm_warning_symbol='&#9888;'                                                " 错误符号
  104. let g:ycm_goto_buffer_command='new-tab'                                        " GoTo*命令的打开方式,默认 'same-buffer'
  105. let g:ycm_key_list_select_completion=['<Leader><Leader><TAB>', '<Down>']        " 选择自动补全信息的按键,默认 ['<TAB>', '<Down>']
  106. let g:ycm_collect_identifiers_from_tags_files=1                                " 允许使用tags指定的文件中的标识符

  107. " 关闭补全时的 preview 窗口
  108. set completeopt-=preview
  109. let g:ycm_add_preview_to_completeopt=0

  110. nnoremap <leader>gc :YcmCompleter GoToDeclaration<CR>                        " 转到声明
  111. nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>                        " 转到定义
  112. nnoremap <Leader>gt :YcmCompleter GetType<CR>                                " 获取变量类型

  113. " 新建文件,自动插入文件头
  114. autocmd BufNewFile *.sh,*.py,*.c,*.cpp,*.h,*.hpp exec ":call SetTitle()"
  115. func SetTitle()
  116.         if expand("%:e") == 'sh'
  117.                 call setline(1, "\#!/bin/bash")
  118.                 call append(line("$"), "")
  119.                 exec ":2"
  120.         elseif expand("%:e") == 'py'
  121.                 call setline(1, "#!/usr/bin/env python")
  122.                 call append(line("$"), "#coding=utf-8")
  123.                 call append(line("$"), "")
  124.                 exec ":3"
  125.         elseif expand("%:e") == 'c'
  126.                 if expand("%") == "main.c"
  127.                         call setline(1, "#include <stdio.h>")
  128.                         call append(line("$"), "")
  129.                         call append(line("$"), "int main(void)")
  130.                         call append(line("$"), "{")
  131.                         call append(line("$"), "\treturn 0;")
  132.                         call append(line("$"), "}")
  133.                         exec ":5"
  134.                 endif
  135.         elseif expand("%:e") == 'cpp'
  136.                 if expand("%") == "main.cpp"
  137.                         call setline(1, "#include <iostream>")
  138.                         call append(line("$"), "")
  139.                         call append(line("$"), "int main(void)")
  140.                         call append(line("$"), "{")
  141.                         call append(line("$"), "\treturn 0;")
  142.                         call append(line("$"), "}")
  143.                         exec ":5"
  144.                 endif
  145.         elseif expand("%:e") == 'h' || expand("%:e") == 'hpp'
  146.                 call setline(1, "#ifndef _".toupper(expand("%:r"))."_".toupper(expand("%:e"))."_")
  147.                 call append(line("$"), "#define _".toupper(expand("%:r"))."_".toupper(expand("%:e"))."_")
  148.                 call append(line("$"), "")
  149.                 call append(line("$"), "#endif")
  150.                 exec ":3"
  151.         endif
  152. endfunc

  153. set noesckeys                " 关闭插入模式识别 <Esc> 开始的功能键
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-9-10 13:06:47 | 显示全部楼层    本楼为最佳答案   
^_^

  1. set number                " 显示行号
  2. set laststatus=2        " 总是显示状态栏
  3. set cursorline                " 高亮显示当前行
  4. set scrolloff=3                " 光标移动到buffer的顶部和底部时保持3行距离
  5. set nowrap                " 禁止折行
  6. set ruler                " 显示光标当前位置
  7. set hlsearch                " 高亮显示搜索结果
  8. set incsearch                " 开启实时搜索
  9. set ignorecase                " 搜索时大小写不敏感
  10. set nocompatible        " 关闭兼容模式
  11. set wildmenu                " vim自身命令行模式智能补全
  12. set noshowmatch                " 不要高亮匹配括号

  13. " 缩进
  14. set tabstop=8
  15. set softtabstop=8
  16. set shiftwidth=8
  17. set noexpandtab
  18. set cindent
  19. set smartindent
  20. set autoindent

  21. let g:python_recommended_style="0"        " 关闭Python的tab

  22. " 关键字高亮
  23. syntax on

  24. " 定义快捷键的前缀,即<Leader>
  25. let mapleader=";"

  26. " 编码格式
  27. set encoding=utf-8
  28. set fileencodings=utf-8,default,gb18030,gbk,gb2312

  29. " 禁止生成临时文件
  30. set nobackup
  31. set noswapfile

  32. " 折叠
  33. set foldmethod=indent        " 缩进折叠
  34. set foldlevel=99        " 启动vim默认不折叠

  35. " 添加C语言标识符文件
  36. set tags+=~/.vim/dict/c.dict

  37. " 设置快捷键将文本复制至系统剪贴板
  38. vnoremap <Leader>y "+y        " 复制选中文本

  39. " 设置快捷键将系统剪贴板内容粘贴至vim
  40. nmap <Leader>p "+p
  41. nmap <Leader>P "+P

  42. " 自动跳到上一次的光标位置
  43. au BufReadPost * if line("'"") > 1 && line("'"") <= line("$") | exe "normal! g'"" | endif

  44. " vundle 环境
  45. set rtp+=~/.vim/bundle/Vundle.vim
  46. "set rtp+=~/Vundle.vim
  47. filetype off                        " required
  48. set nocompatible                " required

  49. call vundle#begin()
  50. Plugin 'gmarik/Vundle.vim'                                " 自己
  51. Plugin 'asins/vimcdoc'                                        " 中文帮助
  52. Plugin 'tomasr/molokai'                                        " 主题
  53. Plugin 'Lokaltog/vim-powerline'                                " 状态栏
  54. Plugin 'scrooloose/nerdcommenter'                        " 快速开关注释
  55. Plugin 'Lokaltog/vim-easymotion'                        " 快速移动光标
  56. Plugin 'mbbill/undotree'                                " 支持分支的undo
  57. Plugin 'octol/vim-cpp-enhanced-highlight'                " 额外的C++语法高亮
  58. Plugin 'majutsushi/tagbar'                                " 基于标签的标识符列表插件
  59. Plugin 'dyng/ctrlsf.vim'                                " 全局文本搜索的插件
  60. Plugin 'terryma/vim-multiple-cursors'                        " 多光标编辑插件

  61. " C/C++补全
  62. Plugin 'SirVer/ultisnips'
  63. Plugin 'honza/vim-snippets'

  64. Plugin 'davidhalter/jedi-vim'                                " Python补全

  65. Plugin 'Valloric/YouCompleteMe'                                " YCM
  66. call vundle#end()
  67. filetype plugin indent on        " required

  68. " 主题
  69. colorscheme ron
  70. "colorscheme molokai

  71. " 将开启tagbar的快捷键设置为<Leader>tb
  72. nmap <Leader>tb :TagbarToggle<CR>
  73. " 设置 tagbar 子窗口的位置出现在主编辑区的左边
  74. let tagbar_left=1
  75. " 设置标签子窗口的宽度
  76. let tagbar_width=32
  77. " tagbar 子窗口中不显示冗余帮助信息
  78. let g:tagbar_compact=1

  79. " 全局文本搜索的插件
  80. nnoremap <Leader>sp :CtrlSF<CR>

  81. " C/C++补全快捷键
  82. let g:UltiSnipsExpandTrigger="<Leader><TAB>"
  83. let g:UltiSnipsJumpForwardTrigger="<Leader><TAB>"
  84. let g:UltiSnipsJumpBackwardTrigger="<Leader><S-TAB>"

  85. " Python补全
  86. let g:jedi#completions_command=""
  87. let g:jedi#goto_assignments_command=""
  88. let g:jedi#goto_definitions_command=""
  89. let g:jedi#goto_command=""
  90. let g:jedi#rename_command="<Leader>r"
  91. let g:jedi#show_call_signatures="0"
  92. let g:jedi#popup_select_first="0"

  93. " YCM
  94. autocmd FileType cpp :let g:ycm_global_ycm_extra_conf='~/.vim/ycm_extra_conf/ycm_extra_conf_cpp.py'
  95. autocmd FileType c :let g:ycm_global_ycm_extra_conf='~/.vim/ycm_extra_conf/ycm_extra_conf_c.py'
  96. let g:ycm_server_python_interpreter='/usr/bin/python2'
  97. let g:ycm_confirm_extra_conf=0                                                " 载入ycm_extra_conf文件,是否提示确认 默认 1
  98. let g:ycm_always_populate_location_list=1                                " 是否显示自动补全诊断location list,默认 0
  99. let g:ycm_seed_identifiers_with_syntax=1                                " 语法关键字补全,默认 0
  100. let g:ycm_min_num_of_chars_for_completion=1                                " 开启自动补全输入的最少字符数,默认 2
  101. let g:ycm_complete_in_comments=1                                        " 在注释中实现自动补全,默认 0
  102. let g:ycm_error_symbol='&#10007;'                                                " 警告符号
  103. let g:ycm_warning_symbol='&#9888;'                                                " 错误符号
  104. let g:ycm_goto_buffer_command='new-tab'                                        " GoTo*命令的打开方式,默认 'same-buffer'
  105. let g:ycm_key_list_select_completion=['<Leader><Leader><TAB>', '<Down>']        " 选择自动补全信息的按键,默认 ['<TAB>', '<Down>']
  106. let g:ycm_collect_identifiers_from_tags_files=1                                " 允许使用tags指定的文件中的标识符

  107. " 关闭补全时的 preview 窗口
  108. set completeopt-=preview
  109. let g:ycm_add_preview_to_completeopt=0

  110. nnoremap <leader>gc :YcmCompleter GoToDeclaration<CR>                        " 转到声明
  111. nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>                        " 转到定义
  112. nnoremap <Leader>gt :YcmCompleter GetType<CR>                                " 获取变量类型

  113. " 新建文件,自动插入文件头
  114. autocmd BufNewFile *.sh,*.py,*.c,*.cpp,*.h,*.hpp exec ":call SetTitle()"
  115. func SetTitle()
  116.         if expand("%:e") == 'sh'
  117.                 call setline(1, "\#!/bin/bash")
  118.                 call append(line("$"), "")
  119.                 exec ":2"
  120.         elseif expand("%:e") == 'py'
  121.                 call setline(1, "#!/usr/bin/env python")
  122.                 call append(line("$"), "#coding=utf-8")
  123.                 call append(line("$"), "")
  124.                 exec ":3"
  125.         elseif expand("%:e") == 'c'
  126.                 if expand("%") == "main.c"
  127.                         call setline(1, "#include <stdio.h>")
  128.                         call append(line("$"), "")
  129.                         call append(line("$"), "int main(void)")
  130.                         call append(line("$"), "{")
  131.                         call append(line("$"), "\treturn 0;")
  132.                         call append(line("$"), "}")
  133.                         exec ":5"
  134.                 endif
  135.         elseif expand("%:e") == 'cpp'
  136.                 if expand("%") == "main.cpp"
  137.                         call setline(1, "#include <iostream>")
  138.                         call append(line("$"), "")
  139.                         call append(line("$"), "int main(void)")
  140.                         call append(line("$"), "{")
  141.                         call append(line("$"), "\treturn 0;")
  142.                         call append(line("$"), "}")
  143.                         exec ":5"
  144.                 endif
  145.         elseif expand("%:e") == 'h' || expand("%:e") == 'hpp'
  146.                 call setline(1, "#ifndef _".toupper(expand("%:r"))."_".toupper(expand("%:e"))."_")
  147.                 call append(line("$"), "#define _".toupper(expand("%:r"))."_".toupper(expand("%:e"))."_")
  148.                 call append(line("$"), "")
  149.                 call append(line("$"), "#endif")
  150.                 exec ":3"
  151.         endif
  152. endfunc

  153. set noesckeys                " 关闭插入模式识别 <Esc> 开始的功能键
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2019-9-10 17:13:44 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-25 04:42

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表