vim 自动补全问题,linux IPC编程和网络编程中怎么自动补全(添出自己的vimrc为大家参考)<解决拉!!!!>

Vim、Emacs配置和使用
回复
tanshuang
帖子: 21
注册时间: 2010-09-28 10:36

vim 自动补全问题,linux IPC编程和网络编程中怎么自动补全(添出自己的vimrc为大家参考)<解决拉!!!!>

#1

帖子 tanshuang » 2010-10-29 11:14

本人是在linux 下网路编程,在输入struct sockaddr结构体时自动补全,但怎么也找不到好的方法
具体步骤首先输入:

代码: 全选

ctags -I __THROW --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --extra=+q -R -f ~/.vim/systags /usr/include /usr/local/include
生成了系统头文件tags
在vimrc中加入:

代码: 全选

set tags+= ~/.vim/systags
可以匹配到系统头文件中的系统函数,但不恩看到参数,很郁闷 :em06

代码: 全选

" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd		" Show (partial) command in status line.
"set showmatch		" Show matching brackets.
"set ignorecase		" Do case insensitive matching
set smartcase		" Do smart case matching
"高亮显示结果
set hlsearch
set incsearch		" Incremental search
"set autowrite		" Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned
set mouse=a		" Enable mouse usage (all modes)

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif
"关闭vi兼容
set nocp
"语法高亮
syntax enable
syntax on
filetype plugin indent on

"taglist
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
let Tlist_Show__One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Auto_Open=0
let Tlist_Auto_Update=1
"色彩
colorscheme default
"minibuff
let g:miniBufExplMapWindowNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplMapCtapSwitchBufs=1
let g:miniBufExplModSelTarget=1
"a.vim配置
nnoremap <silent><F12> :A<CR>
"grep
nnoremap <silent><F5> :Grep<CR>
"supertap
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
"智能补全
set completeopt=longest,menu
"map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
map <C-F12> :!ctags -R --extra=+f --languages=c --langmap=c:+.h --c-kinds=+px --fields=+aiKSz
"设置行号
set nu
"设置trinity
nmap <F8> :TrinityToggleAll<CR>
nmap <F9> :TrinityToggleSourceExplorer<CR>
nmap <F3> :TrinityToggleTagList<CR>
nmap <F4> :TrinityToggleNERDTree<CR>
"设置srcexpl
let g:SrcExpl_winHeight=8
let g:SrcExpl_refreshTime=100
let g:SrcExpl_jumpKey="<ENTER>"
let g:SrcExpl_gobackKey="<SPACE>"
let g:SrcExpl_pluginList=[
			\"__Tag_List__",
			\"_NERD_tree_",
			\"Source_Explorer"
			\]
let g:SrcExpl_searchLoalDef=1
let g:SrcExpl_isUpdateTags=0
let g:SrcExpl_updateTagsCmd="ctags --sort=foldcase -R."
let g:SrcExpl_updateTagsKey="<F12>"
"
:imap <F2> <Esc>:w<CR>
:nmap ` :q!<CR>
:imap { {<CR>}<Esc>kA<CR>
"设置显示中文字体
let &termencoding=&encoding
set fileencodings=utf-8,gbk,ucs-bom,cp936
"NERD_commenter设置
let NERDShutUp=1
""支持单行和多行的选择,//格式
map <c-h> ,c<space>

:inoremap [ []<ESC>i
"mapping
inoremap <expr> <Space>    pumvisible()?"\<C-Y>":"\<Space>"
inoremap <expr> <C-J>      pumvisible()?"\<PageDown>\<C-N>\<C-P>":"\<C-X><C-O>"
inoremap <expr> <C-K>      pumvisible()?"\<PageUp>\<C-P>\<C-N>":"\<C-K>"
inoremap <expr> <C-U>      pumvisible()?"\<C-E>":"\<C-U>" 
inoremap <expr> j	   pumvisible()?"\<Down>":"\j"
inoremap <expr> k	   pumvisible()?"\<Up>":"\k"
"不生成备份文件
set nobackup
set nowritebackup
"
set ofu=syntaxcomplete

"补全
inoremap <F3> <C-X><C-N>
inoremap <F4> <C-X><C-P>
"自动缩进
set autoindent
set showmatch
set smartindent
set ai!
"高亮显示txt文档
let tlist_txt_settings = 'txt;c:content;f:figures;t:tables'
au BufRead,BufNewFile *.txt setlocal ft=txt
set cindent
"设置ctags.vim
let g:ctags_path='/usr/local/bin/ctags'
let g:ctags_statusline=1
" build tags of your own project with Ctrl-F12
" map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q
" .<CR>
"
" " OmniCppComplete
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
map  <F7>   <Plug>ShowFunc
map! <F7>   <Plug>ShowFunc 
"cscope
:set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
"自动运行gcc,g++
" C的编译和运行
 map <F6> :call CompileRunGcc()<CR>
 func! CompileRunGcc()
 exec "w"
 exec "!gcc % -o %<"
 exec "! ./%<"
 endfunc

 " C++的编译和运行
 map <F5> :call CompileRunGpp()<CR>
 func! CompileRunGpp()
 exec "w"
 exec "!g++ % -o %<"
 exec "! ./%<"
 endfunc
" 显示状态栏 (默认值为 1, 无法显示状态栏)
 set laststatus=2

 " 状态行颜色
 highlight StatusLine guifg=SlateBlue guibg=Yellow
 highlight StatusLineNC guifg=Gray guibg=White

 function! CurDir()
 let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
 return curdir
 endfunction
 "自动生成tags标志
 au BufWrite *.cpp,*.h,*.c,*.rl,*.def call system("ctags -a  -f ~/.vim/tags/local/ctags --extra=+q " . expand("%:p"))
 au BufWrite *.rb call system("ctags -a -f ~/.vim/tags/local/rbtags --extra=+q " . expand("%:p"))
 au BufWrite *.py call system("ctags -a -f ~/.vim/tags/local/pytags --extra=+q " . expand("%:p"))
 au BufWrite *.java call system("ctags -a -f ~/.vim/tags/local/javatags --extra=+q " . expand("%:p"))
 au BufRead,BufNewFile *.rb setlocal tags+=~/.vim/tags/local/rbtags,~/.vim/tags/linux/rbtags
 au BufRead,BufNewFile *.cpp,*.h,*.c setlocal tags+=~/.vim/tags/local/ctags,~/.vim/tags/linux/ctags,~/.vim/systags
 au BufRead,BufNewFile *.rl,*.def setlocal tags+=~/.vim/tags/local/ctags,~/.vim/tags/linux/ctags
 au BufRead,BufNewFile *.py setlocal tags+=~/.vim/tags/local/pytags,~/.vim/tags/linux/pytags
 au BufRead,BufNewFile *.java setlocal tags+=~/.vim/tags/local/javatags,~/.vim/tags/linux/javatags

 set tags=./.tags;${HOME}
上次由 tanshuang 在 2010-10-31 22:28,总共编辑 1 次。
tanshuang
帖子: 21
注册时间: 2010-09-28 10:36

Re: vim 自动补全问题,linux IPC编程和网络编程中怎么自动补全(添出自己的vimrc为大家参考)

#2

帖子 tanshuang » 2010-10-31 22:27

呵呵,自动补全解决了拉,哈哈哈,不知道有有多高兴

主要是我没有很好按提示去做 对于C语言 :

代码: 全选

sudo ctags -R -f  ~/.vim/systags -I  __THROW --c-kinds=+p --fields=+lS /usr/include/ 
vimrc中加入:

代码: 全选

set tags+=~/.vim/systags
tanshuang
帖子: 21
注册时间: 2010-09-28 10:36

Re: vim 自动补全问题,linux IPC编程和网络编程中怎么自动补全(添出自己的vimrc为大家参考)<解决拉!

#3

帖子 tanshuang » 2010-10-31 22:55

呵呵,自动补全解决了拉,哈哈哈,不知道有有多高兴

主要是我没有很好按提示去做 对于C语言 :

代码: 全选

sudo ctags -R -f  ~/.vim/systags -I  __THROW --sort=yes --c-kinds=+p --fields=+liaS --extra=+q  /usr/include/ 
vimrc中加入:

代码: 全选

set tags+=~/.vim/systags
忘了告诉大家,我装的自动补全插件:autoproto.vim ,echofunc.vim 官网上下:http://www.vim.org/
--fields=+lS是为echofunc.vim服务的,生成函数原型,别多加,别少加
autiproto.vim 装上没坏处,嘻嘻

我也有一个压箱底的交出来:
大家装个help.vim这个插件把,呵呵,在官网上下,不过刚下来的有机个地方需要修改,我的是这样的
这个插件功能:
按下:当光标移到想要看帮住的函数上敲<F1>,
在窗口就会一半的帮助文档,按q就推出,
q:推出
o:全屏
S:概要
D:描述

代码: 全选

sudo vim ~/.vim/plugin/help.vim
将以下行注释掉
84,119
请大家记住c.vim ,code_complete,ctags,taglist,cscope,一定装,有问题大家一定坚持,不放弃,我们一起解决,vim 很强大,没有神马做不到了

上传我的系统头文件tags,希望对你有用, :em02 ,大家不要批评我啊,如有不对,我会努力的
上次由 tanshuang 在 2010-11-01 17:59,总共编辑 1 次。
tanshuang
帖子: 21
注册时间: 2010-09-28 10:36

Re: vim 自动补全问题,linux IPC编程和网络编程中怎么自动补全(添出自己的vimrc为大家参考)<解决拉!

#4

帖子 tanshuang » 2010-10-31 22:59

systags太大了传补上郁闷了,大家自己生成把,按上面的就没问题的饿
头像
lainme
论坛版主
帖子: 7805
注册时间: 2008-09-13 19:17
系统: Arch Linux (x86_64)
联系:

Re: vim 自动补全问题,linux IPC编程和网络编程中怎么自动补全(添出自己的vimrc为大家参考)<解决拉!

#5

帖子 lainme » 2010-11-02 14:37

srcexpl那个,nerd_tree能换成netrw不
回复