Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to get Vim in command mode to complete words from the current file? Say I have this file:


and I enter command line mode

:myruncommand o|

where | denotes the cursor position. How do I make Vim complete one or once when pressing Tab?

share|improve this question
Quote from the script description: "In ':' mode, completion is available only after a '/'." Not really what I need. –  Nickolay Kolev Sep 20 '11 at 7:45

3 Answers 3

up vote 2 down vote accepted

It's not possible natively, but it took about one minute to find this script and this one on vim.org.

share|improve this answer

Completion is available if you enter history of command mode. Very handy to alter or repeat previously used commands.

Press q: in normal mode to enter command history pane.

See http://vim.wikia.com/wiki/Using_command-line_history for more details.

share|improve this answer

Although true that this can't be completed natively with 'tab', there is the possibility of:

  • Entering the command you want in command line mode. For the example above this was:

    :myruncommand o
  • Now press Ctrl-F to enter the command window.

  • Use A move to the end of the line and enter Insert mode.
  • Use Ctrl-N / Ctrl-P to open keyword completion and select the option you want - in this example both one and once should be available since they are in an open buffer.

I've added this answer because my search for "vim complete word in command mode" brought me here and it seems to be a workable solution, even though it doesn't use the 'tab' key.

This works for me in Vim 7.4

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.