Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How display actual syntax highlight in vim?

Recently I wrote a text file without a file extension with the vim text editor and got text highlightning for all words between singel quotes like 'word' and all words ending with a colon like word:

I like this kind of highlightning.

But because I havent typed any command, which usually starts with ESC :command, I was surprised how this could happen.

Is there a command to display the actual syntax highlight which is in use?

I already have tried the command :set syntax=php which seems simliar only with different color for words like word:

Does anyone have suggestions?

like image 949
John Goofy Avatar asked Aug 03 '16 13:08

John Goofy


People also ask

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

How do you highlight 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 you highlight syntax?

Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms.

How do I set default syntax in vim?

Just type :e ~/. vimrc to vim, type in the line and save (:w).


2 Answers

Try entering the command

:echo &syntax

This will display the value that the syntax variable has been set to.

like image 163
zarak Avatar answered Nov 04 '22 10:11

zarak


set option=value "set the option with value
set option?      "read/print the current value of the option
set option!      "set the option with opposite value, like set nu and set nu!

the option value is also saved in variable &option so you can read in script way.

like image 35
Kent Avatar answered Nov 04 '22 10:11

Kent