sponsor Vim development Vim logo Vim Book Ad

CmdlineComplete : complete command-line (: / etc.) from the current file

 script karma  Rating 185/63, Downloaded by 4726  Comments, bugs, improvements  Vim wiki

created by
Yuheng Xie
 
script type
utility
 
description
When editing the command-line (: / etc.), press Ctrl-P or Ctrl-N to complete the word before the cursor, using keywords in the current file. E.g: you want to search for "elephant" in the buffer, just type /ele and press Ctrl-P. So long as "elephant" is in the buffer, you will get "ele" completed into "elephant".

This script is functional similar with (but far more better than) SearchComplete vimscript #474 (version 1.1).
 
install details
Just drop the script file "cmdline-complete.vim" into the plugin directory. Restart VIM.

If you want to use other keys instead of default <c-p> <c-n>, you may say in your .vimrc
cmap <c-y> <Plug>CmdlineCompleteBackward
cmap <c-e> <Plug>CmdlineCompleteForward
this will use Ctrl-Y for search backward and Ctrl-E for search forward.

Note: I don't think it's good to use Tab and Shift-Tab for completion, since it will disable vim's original cmdline-completion.

Without python, speed will be a bit slow with large file (e.g. > 100K). Compile your vim with python is recommended.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
cmdline-complete.vim 1.1.3 2008-07-18 7.0 Yuheng Xie added support for 'iskeyword'
cmdline-complete.vim 1.1.2 2008-07-13 7.0 Yuheng Xie added support for 'ignorecase' and 'smartcase'
cmdline-complete.vim 1.1.1 2008-07-09 7.0 Yuheng Xie trival fix for 1.1
cmdline-complete.vim 1.0.4 2008-05-08 7.0 Yuheng Xie fix for environment where python was found without module re
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github