JavaScript is the scripting language for the web. On the other hand, Vim is the editor of choice for many programmers. Being feature-rich, Vim can auto-complete JavaScript syntaxes. To use the feature, you'll need to enable it first.

Enter the following while in Vim's command mode to enable the feature.

Step-by-step video guide:
:set omnifunc=javascriptcomplete#CompleteJS

You can now auto-complete JavaScript syntaxes by pressing Ctrl + x followed by Ctrl + o while partially typing JavaScript codes.

The following is a sample screenshot.

You can use the arrow key to navigate through the list to choose your desired auto-complete suggestion.

Automatically enable auto-complete for JavaScript files

To automatically enable JavaScript to auto-complete every JavaScript file, add the following line to your ~/.vimrc;

autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
Discuss the article:

Comment anonymously. Login not required.