thgvyg
Last Updated: February 25, 2016
·
1.761K
· NIA

Reset Vim syntax highlighting

Ever got irritated when Vim fails to properly highlight syntax in complex file opened in the middle? For example, when you re-open HTML file with a huge <script> block, and Vim doesn't know that it is script, because its begining is far, far away:
No JS highlighting
It is very annoying to scrool up and back down to make Vim catch it! No need to do this anymore! This SO answer reveals the fix:

:syn sync fromstart

...aaand....
Highlighting fixed
So, why not make a map in your vimrc?

nmap <C-s> :syn sync fromstart<CR>

Now Control+S will Sync your Syntax.

Read that SO answer for more details on this command.