Using vi, I want to display files in distinguished colors in unix. If I save a file as .sql
or .java
it will highlight the keywords. I want to make changes to which words are highlighted, and in what color.
How do I control syntax highlighting and color schemes with various vi file extensions?
Enabling syntax color schemePress the "i" key to enter insert mode. Hold Shift and hit : then type wq to save and quit the file. You should now be able to use vi and the colorscheme you choose to edit files.
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.
Syntax highlighting enables Vim to show parts of the text in another font or color. Those parts can be specific keywords or text matching a pattern. Vim doesn't parse the whole file (to keep it fast), so the highlighting has its limitations.
Type following command after a colon:
:set ft=sql.
I just did it by putting :syntax on
. I suppose you want to save the settings so it can be highlighted each time you open one of those files, in which case the answer by Eric it's the correct one.
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