Vim can be automatically completed based on the dictionary of the user's meaning. 1) dictionary: Vim uses a series of words in a text file. If it is written in the same line, vim will automatically split according to the delimiter in iskeyword. If some special characters are required during full-time completion, such as entering PR, printf will appear after completion. (, you not only need to add printf. (, you also need to set the symbol in iskeyword. and symbol (add, the method is to add set iskeyword + =. To the vimrc file ., (2) Use: After compiling the dictionary, add such a line of code to the vimrc file (change the path to the path of the dictionary file) set dictionary-= $ Vim/dic.txt dictionary + = $ Vim/dic.txt enter a part of the word in input mode, and then press <Ctrl-x> <Ctrl-k>, the auto-completion option is displayed. If there are multiple options, you can use ctrl-N and Ctrl-P to select 3) shortcut key: if the <Ctrl-x> <Ctrl-k> combination key is too troublesome, you can add the dictionary Completion list directly to the default Completion list, in vimrc, add the following code set complete-= K Complete + = K. in input mode, enter a part of the word, press <Ctrl-N> to start auto-completion. If you are used to using the tab key to complete, here is a code for intelligent tab completion, which can be added to vimrc, it automatically selects the completion mode based on the context:
inoremap <tab> <c-r>=Smart_TabComplete()<CR>
function! Smart_TabComplete() let line = getline('.') " current line let substr = strpart(line, -1, col('.')+1) " from the start of the current " line to one character right " of the cursor let substr = matchstr(substr, "[^ \t]*$") " word till cursor if (strlen(substr)==0) " nothing to match on empty string return "\<tab>" endif let has_period = match(substr, '\.') != -1 " position of period, if any let has_slash = match(substr, '\/') != -1 " position of slash, if any if (!has_period && !has_slash) return "\<C-X>\<C-P>" " existing text matching elseif ( has_slash ) return "\<C-X>\<C-F>" " file matching else return "\<C-X>\<C-O>" " plugin matching endifendfunction