vim autocomplete - How to auto-complete words with the vim editor

A vi/vim FAQ I often get is, "Does vi have any sort of auto-complete feature?"

Answer: Yes, just use the [Ctrl]p keystroke after you've entered some text.

Auto-complete example

Here's a quick example. Assume you have this text in a vi/vim editor:

Four score and seven years ago ... consecrate ...

Now, assume that you are somewhere else in this file, and you want to re-enter the word consecrate, but you don't want to type out the whole word. All you have to do is start typing the word, like this:


and then hit the [Ctrl]p key sequence. At this point, if this sequence of characters is only matched to the word consecrate, vi will automatically complete the entire word. Otherwise, if there are other words that begin with the characters cons (like "consult"), vi will offer you a list of options to choose from. Just choose "consecrate" from that list.


Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.