笔记---Linux---Vim自动补齐的配置

来源:互联网 发布:知乎 商城模块 编辑:程序博客网 时间:2024/06/06 07:18

2014-10-06

关于VIm自动补齐的配置:

>>1<<

配置文件在/etc/vim这个文件夹里。/etc这个目录主要存放系统配置文档的。

/etc/vim里的配置文件不建议修改,这个是全局的,作用于所有用户。一般直接在家目录底下建立配置文档就可以了。


http://blog.csdn.net/namecyf/article/details/7787479vim配置及插件安装管理(超级详细)

http://blog.csdn.net/wendy260310/article/details/18035555  Vim函数自动补齐(包括库函数)

>>2<<

安装ctags,下载cpp_src.tar,下载OmniCppComplete,全都放到/etc/vim/目录下(分别放在不同的目录)

即:将cpp_src解压之后放在tags目录下

将omnicppcomplete解压就可以

进入tags目录,输入命令:

ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -f cpp cpp_src

生成一个cpp文件(即tags)。

在vimrc中配置:

/etc/vim/vimrc

" configure tags - add additional tags here or comment out not-used ones
set tags+=/etc/vim/tags/cpp
set tags+=/root/2014/tags //此路井下的文件都可以自动补齐

//试过,发现别的目录下的文件也可自动补齐
map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR>

" OmniCppComplete
filetype plugin on
syntax enable
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
配置完之后
在相应的目录下,打开vim文件,命令模式下按Ctrl-F12,即可生成一个tags文件。


自动补齐括号

:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
else
        return a:char
endif
endfunction 


关于虚拟机上网问题

若虚拟机上不了网,可在  编辑->虚拟网络编辑器  中设置做相应的设置

0 0
原创粉丝点击