Has anyone else found VIM's syntax highlighting of Javascript sub-optimal? I'm finding that sometimes I need to scroll around in order to get the syntax highlighting adjusted, as sometimes it mysteriously drops all highlighting.
Are there any work-arounds or ways to fix this? I'm using vim 7.1.
After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.
VIM is an alternative and advanced version of VI editor that enables Syntax highlighting feature in VI. Syntax highlighting means it can show some parts of text in another fonts and colors. VIM doesn't show whole file but have some limitations in highlighting particular keywords or text matching a pattern in a file.
Vim supports basic syntax highlighting for JavaScript but I found it suboptimal especially when it comes to modern ES2015+ syntax, and it doesn't support JSX when working with React. I found that vim-javascript and vim-jsx solved my problems in both instances.
Press 1 to highlight the current visually selected text, or the current word (if nothing is selected). Highlight group hl1 is used. Press 2 for highlight hl2 , 3 for highlight hl3 , etc. Press 0 to remove all highlights from the current visually selected text, or the current word.
Add the text, “syntax on ” anywhere in the file to enable syntax highlighting permanently for vim editor. Save and close the file by typing ‘:x’. For disabling the feature, just re-open . vimrc file, change the text “ syntax on ” to “syntax off” and save the file.
Here, a bash file named login.sh with the following content is used. Run the following command to open the file in vim editor. Syntax highlighting is on for vim editor by default. The content of login.sh will be displayed with the following format when the syntax highlighting is on.
Many new features are added in vim editor which are not available in old vi editor. One of useful features of vim is syntax highlighting. The readability of any source code or configuration file can be increased by using different front and color for different part of the file. This task can be done by using syntax highlighting feature of vim.
You can select syntax language after opening a file in vim editor. Many syntax languages exist for the vim editor, such as “php”, “perl”, “python”, “awk” etc. Open a python file named average.py in the vim editor. The content of the file looks like the following image by the default syntax of vim editor.
You might like to try this improved Javascript syntax highlighter rather than the one that ships with VIMRUNTIME.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With