Add the following code snippet to your .vimrc or other file and enter it in .vimrc:
if did_filetype()
finish
endif
if getline(1) =~ '#!/usr/bin/env node'
setfiletype javascript
endif
It just sets the file type in js when the first line of file matches '#! / Usr / bin / env node' is pretty much explanatory. This is also described in the file type help: check file: filetype
source
share