Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Syntax highlighting in vim on a per-buffer basis

I currently have to edit some very large XML files, which slows down syntax highlighting to a point where it's absolutely unusable - it takes multiple seconds to update the screen after a search operation, for example.

When disabling syntax highlighting (:syn off), the same operations happen instantaneously. Unfortunately, disabling syntax highlighting appears to happen globally, so all other files now have it disabled as well.

So: Is there a way to only disable syntax highlighting for a given buffer?

like image 648
Dave Vogt Avatar asked Jul 30 '12 14:07

Dave Vogt


2 Answers

You can set :syntax manual and then enable it with set syntax=ON in the buffers you like. Also see :help :syn-manual.

like image 148
Benedikt Köppel Avatar answered Oct 14 '22 16:10

Benedikt Köppel


Answering my own question: A simple hack would be to force the syntax of the file to something that vim doesn't know how to highlight: :set syntax=unknown

However, this seems a bit hacky - maybe there's another solution?

like image 36
Dave Vogt Avatar answered Oct 14 '22 18:10

Dave Vogt