Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I want is the following:

  1. Pressing TAB completes the current word I'm writing with the longest common prefix, and nothing more. I don't want to cycle through any options either, pressing TAB again should return me to the original string preferably, or do nothing if that's not possible.

  2. Pressing CTRL + SPACE should pop up a menu showing all possible completions like the default vim.

Is this possible? I've found cycling through options / opening menus is extremely distracting for me while programming, and encourages the behaviour to keep cycling and hope that the completion I'm looking for is there.

share|improve this question

For the longest common text, use

:set completeopt+=longest

To avoid showing any other matches:

:set completeopt-=menu

<C-N> / <C-P> will still show the other matches; learn to use <C-E> to stop completion and go back to the originally typed text.

For the mapping:

function s:EnableCompleteMenu()
    set completeopt+=menu
    return ''
inoremap <expr> <SID>EnableCompleteMenu s:EnableCompleteMenu()
inoremap <script> <C-Space> <SID>EnableCompleteMenu<C-N>

You could also use <C-P> for showing matches in the other direction. Note that the <C-Space> mapping probably only works in GVIM. If you want to use that together with the commands from above, you need to write a similar wrapper (with :set completeopt-=menu) and overload the other completion commands (<C-N>, etc.) with it.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .