On Tue, 23 Nov 2010, Aman Jain wrote:

Hi

Somewhat in the spirit of filename completion (using tab or CTRL-D) in EX mode, is it possible to autocomplete search terms when i am trying to search for some text?

For example:
/msg <TAB>
should give all suggestions of entries starting with msg, so that I don't have to type the whole search term
"msg_foo_bar_on_and_on"

(As I recently learned on the Zsh mailing list,) this is already provided by cmdline-completion:

:help cmdline-completion

But not with <Tab>, rather <Up> and <Down> arrows.

e.g.: /msg<Up> would likely bring up: /msg_foo_bar_on_and_on

If you want <Tab> to function that way for searches, you might be able to set something up with the CmdwinEnter and CmdwinLeave autocmds:

" This doesn't work as-is, not quite sure how to combine the <expr>-like
" ternary and the special-key notation/quotation working together
let g:TabShouldSearch = 0

" rough idea: in command mode, let <tab> act as <up>, otherwise as <tab>
cnoremap <expr> <Tab> g:TabShouldSearch ? '\<Up>' : '\<Tab>'

aug TabSearch
    au!
        " when entering or leaving forward (/) or backward (?) search modes,
        " toggle the behavior of the <Tab> mapping
    au CmdwinEnter,CmdwinLeave [/?] let g:TabShouldSearch != g:TabShouldSearch
aug END

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to