How to use ctags to autocomplete in vim

I am trying to develop an Android project in vim.But to find it a little boring to search in ctags for one method. Is there a way to show autocomplete list in vim using ctags?

thanks

this is my version of ctags below:

Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert Compiled: Mar 21 2011, 10:34:51 Addresses: < dhiebert@users.sourceforge.net >, http://ctags.sourceforge.net Optional compiled features: +wildcards, +regex 

and vim version:

 Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert Compiled: Mar 21 2011, 10:34:51 Addresses: < dhiebert@users.sourceforge.net >, http://ctags.sourceforge.net Optional compiled features: +wildcards, +regex ccheng@ccheng-desktop :~$ vim --version VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 24 2011 07:10:07) Included patches: 1-35 Modified by pkg-vim-maintainers@lists.alioth.debian.org Compiled by buildd@ Huge version without GUI. Features included (+) or not (-): +arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra -perl +persistent_undo +postscript +printer +profile +python/dyn +python3/dyn +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wall -g -O2 -D_FORTIFY_SOURCE=1 Linking: gcc -Wl,--as-needed -o vim -lm -lncurses -lselinux -lacl -lgpm 

my .vimrc file is:

  1 set autochdir 2 filetype plugin indent on 3 set nu 4 set tags=./tags 5 set path=.,..,../.. 6 set tabstop=4 7 set hlsearch 8 set cscopequickfix=s-,c-,d-,i-,t-,e- 9 set tags=$HOME/gingerbread/frameworks/tags,$HOME/gingerbread/packages/provid ers/ContactsProvider/tags 10 11 :" Only do this part when compiled with support for autocommands. 12 :if has("autocmd") 13 : autocmd Filetype java setlocal omnifunc=javacomplete#Complete 14 :endif 15 setlocal completefunc=javacomplete#CompleteParamsInfo 
+7
source share
3 answers

I want to clarify: it seems that you already have ctags installed and would like to know how to use it to autocomplete method names, right?

As romainl mentions, <Cn> and <Cp> are what you are looking for. They are complete using next match and complete using previous match , respectively.

However, they are not the only vim autocomplete types; see :he ins-completion for the rest (including spelling and file names). One specific completion that I would like to point out is <Cx><Co> (omni-completion), which you may find useful.

If you weren’t just doing autocompletion: in this similar SO question, the accepted answer of richq contains some useful information about ctags in general.

+9
source

I did not try autocomplete in VIM, but a quick search was found http://vim.wikia.com/wiki/Any_word_completion : the option "complete" controls the search for keywords (including files, tag files , buffers, etc.).

+1
source

You can complete everything with [TAB], with this in vimrc. We use [char] [char] [dot] [tab] to trigger tag completion. Also see fooobar.com/questions/392284 / ... for how to integrate spelling, thesaurus, and vocabulary.

  :inoremap <Tab> <CR>=MoshTabOrComplete()<CR> function! MoshTabOrComplete() if col('.') > 3 \ && strpart( getline('.'), col('.')-3, 4 ) =~ '^[a-zA-Z]\+[.]' " prev 2 char are alpha+dot? " Tag-completion eg. print.<tab> will complete to printf or println return "\<BS>\<Cx>\<C-]>" endif " if exists("g:MoshThesaurusOmniCompleter") && col('.') > 3 " \ && strpart( getline('.'), col('.')-3, 4 ) =~ '^[a-zA-Z]\+[!%?~-]' " prev 2 char are alpha+punct? " Calls MoshThesaurusOmniCompleter " Test: qieut!<tab> will spell correct to quiet, more tests in ./thesaurus-omni.vim " return "\<Cx>\<Co>" " endif if col('.') > 1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' " prev char is alphabet? " Usual omni-completion return "\<CN>" endif " Insert regular TAB return "\<Tab>" endfunction 
0
source

Source: https://habr.com/ru/post/898181/


All Articles