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.
: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
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.