Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript syntax highlighting in vim

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.

like image 823
Steve M Avatar asked Sep 12 '08 12:09

Steve M


People also ask

How do I enable syntax highlighting in vim?

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.

Does vim support 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.

Can you write JavaScript in vim?

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.

How do I highlight keywords in vim?

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.

How do I enable syntax highlighting in Vim?

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.

How do I open a bash file in Vim editor?

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.

What new features are added in Vim editor?

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.

How to select syntax language after opening a file in 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.


1 Answers

You might like to try this improved Javascript syntax highlighter rather than the one that ships with VIMRUNTIME.

like image 178
Rob Wells Avatar answered Sep 22 '22 05:09

Rob Wells