安装了这几个开发包后,就可以在VIM写一些网络程序了,不过以后可能会用到一些第三方库,比如MySQL的C++ API--MySQL++,以及线程池库,MySQL++我都没用过,之前都是自己用MySQL C API简单的包装了一个C++类来操作MySQL。而线程池库,自己没能力用pthread来写线程池,试用过glib的线程池类,但用着不太顺手。至于boost中的线程池,以前好像用过,但具体的感受已经忘记了。
以下命令在root权限下执行
cd /usr/include
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
cd /usr/local/include
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
然后编辑.vimrc(/etc/vim/vimrc),添加如下内容:
set tags+=/usr/include/tags
set tags+=/usr/local/include/tags
set tags+=./tags
"-- omnicppcomplete setting --
set completeopt=menu,menuone
let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype in popup window
let OmniCpp_GlobalScopeSearch=1
let OmniCpp_DisplayMode=1
let OmniCpp_DefaultNamespaces=["std"]
set nocp
filetype plugin on
hi PmenuSel ctermfg=7 ctermbg=4 "改变选中菜单颜色
"hi Pmenu ctermfg=7 ctermbg=4 "改变菜单颜色
set nu "显示行号
set et sw=4 ts=4 sts=4 "Tab宽度
set cindent "C风格缩进
set smartindent "为C程序提供自动缩进
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o "不要自动添加新的注释行
set paste "粘贴时取消自动缩进功能