Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

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
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

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 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
I should've guessed there was an easy way to go to the command/search buffer while already entering a command or search string! Thanks! I've added an answer based on yours, for the way I already knew. But doubtlessly, Ctrl+F is more convenient in many cases. – Michael Scheper Dec 21 '15 at 0:09

jamesc's answer would often be the most convenient, but for when you know ahead of time that you'll want to use autocomplete for a command or search string, or other functions only available in a buffer, here's another way to get to the appropriate buffers:

  • Type q : to open the command buffer
  • Type a to start entering the new command: myruncommand o
  • Use Ctrl+N/Ctrl+P for keyword completion, just as in jamesc's answer

Basically, q : does the same thing as : Ctrl+F: let you enter commands as if you're entering text in a buffer. Similarly, q / and / Ctrl+F both let you type search strings in a buffer.

share|improve this answer
Great answer. Command buffer is something that I'd definitely like to be better at using. – jamesc Dec 22 '15 at 9:17
@jamesc: I'm glad it was helpful for you. I didn't know about Ctrl+F, so your answer helped me, too. – Michael Scheper Dec 22 '15 at 19:36

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.