vim自动补全插件clang_complete

本文介绍了如何在Linux环境下配置vim编辑器,通过安装clang和clang_complete插件,实现C++代码的自动补全功能。详细步骤包括安装clang,克隆并安装clang_complete插件,以及修改.vimrc文件设置相关选项,如启用补全窗口和指定C++标准。测试结果显示,在代码中输入`std::`后能自动提示并显示vector等选项。
fedora 20下安装vim的C++补全插件clang_complete

1.安装clang

yum install clang

2.安装clang_complete插件

git clone git@github.com/oyjb/clang_complete.git

cd clang_complete

make install


3.修改.vimrc
let g:clang_complete_copen=1
let g:clang_close_preview=1
let g:clang_user_options='-std=c++11'
let g:neocomplcache_enable_at_startup = 1 
set completeopt=longest


4.测试

[cpp]   view plain copy 在CODE上查看代码片 派生到我的代码片
  1. #include <vector>  
  2. int main()  
  3. {  
  4.      std:://这个地方会出现提示,再输入v就出现vector的选项  
  5. }  

vimrc配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
if   v:lang =~  "utf8$"   || v:lang =~  "UTF-8$"
    set fileencodings=ucs-bom,utf-8,latin1
endif
 
set nocompatible    " Use Vim defaults (much better!)
set bs=indent,eol,start        "   allow backspacing over everything  in   insert mode
"set ai            "   always set autoindenting on
"set backup        "   keep a backup file
set viminfo= '20,\"50   " read/write a .viminfo file, don' t store more
             " than 50 lines of registers
set history=50     "   keep 50 lines of command line history
set ruler       " show the cursor position all the time
 
"   Only  do   this   part when compiled  with   support  for   autocommands
if   has( "autocmd" )
   augroup redhat
   autocmd!
   " In text files, always limit the width of text to 78 characters
   "   autocmd BufRead *.txt set tw=78
   " When editing a file, always jump to the last cursor position
   autocmd BufReadPost *
   \ if line(" '\"") > 0 && line ("' \"") <= line( "$" ) |
   \   exe  "normal! g'\""   |
   \ endif
   " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
   autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
   "   start  with   spec file template
   autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
   augroup END
endif
 
if   has( "cscope" ) && filereadable( "/usr/bin/cscope" )
    set csprg=/usr/bin/cscope
    set csto=0
    set cst
    set nocsverb
    " add any database in current directory
    if filereadable(" cscope.out ")
       cs add $PWD/cscope.out
    "   else   add database pointed to by environment
    elseif $CSCOPE_DB !=  ""
       cs add $CSCOPE_DB
    endif
    set csverb
endif
 
" Switch syntax highlighting on, when the terminal has colors
"   Also  switch   on highlighting the last used search pattern.
if   &t_Co > 2 || has( "gui_running" )
   syntax on
   set hlsearch
endif
 
filetype plugin on
 
if   &term== "xterm"
      set t_Co=8
      set t_Sb=[4%dm
      set t_Sf=[3%dm
endif
 
" Don't wake up system with blinking cursor:
"   http: //www.linuxpowertop.org/known.php
let &guicursor = &guicursor .  ",a:blinkon0"
 
syntax enable
set background=dark
colorscheme solarized
set guifont=dejavu\MONACO\ 12
 
 
set nu
set showmode
set autoindent
set showmatch
set tabstop=4
 
set mouse=a
set selection=exclusive
set selectmode=mouse,key
 
au InsertLeave *.c write
au InsertLeave *.cpp write
au InsertLeave *.txt write
au InsertLeave * write
 
set cursorline
set fileencodings=utf-8,gb2312,gbk,gb18030,big5
set encoding=euc-cn
set fenc=utf-8
set enc=utf-8
set ambiwidth=double
 
let g:clang_complete_copen=1
let g:clang_close_preview=1
let g:clang_user_options='-std=c++11 '
let g:neocomplcache_enable_at_startup = 1 
set completeopt=longest
 
map <F4> ms:call AddAuthor()<cr>' s
function   AddAuthor()
         let 
         while   n < 5
                 let line = getline(n)
                 if   line =~ '^\s*\*\s*\S*Last\s*modified\s*:\s*\S*.*$'
                         call UpdateTitle()
                         return
                 endif
                 let n = n + 1
         endwhile
         call AddTitle()
endfunction
 
function   UpdateTitle()
         normal m '
         execute ' /* Last modified\s*:/s@:.*$@\=strftime( ": %Y-%m-%d %H:%M" )@ '
         normal "
         normal mk
         execute ' /* Filename\s*:/s@:.*$@\=":  ".expand(" %:t ")@'
         execute " noh "
         normal 'k
         echohl WarningMsg | echo " Successful  in   updating the copy right. " | echohl None
endfunction
function AddTitle()
         call append(0," /********************************************************** ")
         call append(1,"   * Author        : oyjb ")
         call append(2,"   * Email         : jbouyang@126.com ")
         call append(3,"   * Last modified :  ".strftime(" %Y-%m-%d %H:%M "))
         call append(4,"   * Filename      :  ".expand(" %:t "))
         call append(5,"   * Description   :  ")
         call append(6,"   * *******************************************************/ ")
         echohl WarningMsg | echo " Successful  in   adding the copyright." | echohl None
endfunction
资源介绍“基于Spring Boot开发的智能学习平台系统”这一毕业设计项目,是面向现代化教育需求,利用Java语言及Spring Boot框架打造的一款智能化、高效化的学习管理系统。此系统旨在为学生提供个性化的学习体验,为教师提供便捷的教学管理,为教育机构提供数据化的教学分析。该系统涵盖了用户管理、课程管理、学习进度跟踪、智能推荐等多个核心功能。通过用户管理模块,平台可以实现用户注册、登录、个人信息维护等基础操作,确保用户信息的安全与隐私。课程管理模块则支持教师发布、编辑课程信息,并允许学生浏览、选择感兴趣的课程进行学习。学习进度跟踪功能能够实时记录学生的学习情况,为教师和学生提供学习进度的可视化展示。智能推荐是该系统的一大亮点。通过对学生的学习行为和成绩数据进行深入分析,系统能够为用户推荐个性化的学习资源,帮助用户高效学习,提升学习效果。此外,系统还提供了数据分析功能,为教育机构提供教学质量的量化评估,为教学改进提供数据支持。该项目采用Spring Boot框架进行开发,充分利用了Spring Boot的自动化配置和简化开发的特性,使得系统具有高度的可扩展性和可维护性。同时,项目代码结构清晰,逻辑严谨,易于理解和二次开发。此毕业设计项目不仅展示了学生在Java编程和Spring Boot框架应用方面的扎实功底,更体现了学生对于现代教育技术的深刻理解和创新应用。该系统不仅适用于学校等教育机构,也可为在线教育平台提供技术支持,具有广阔的应用前景和市场价值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值