Split windows and syntax highlighting

17 views
Skip to first unread message

Matthias Pitzl

unread,
Sep 24, 2012, 11:51:10 AM9/24/12
to vim...@googlegroups.com
Hi there!

Is it somehow possible to do a :syn off only for one specific window?

Thanks in advance!

-- Matthias

Christian Brabandt

unread,
Sep 24, 2012, 1:56:14 PM9/24/12
to vim...@googlegroups.com
Hi Matthias!

On Mo, 24 Sep 2012, Matthias Pitzl wrote:

> Hi there!
>
> Is it somehow possible to do a :syn off only for one specific window?
>
> Thanks in advance!

Yes, if you use :setl syntax=off
:syn off will turn off syntax highlighting globally.

regards,
Christian
--
Der Aberglauben schlimmster ist,
den seinen f�r den ertr�glicheren zu halten.
-- Gotthold Ephraim Lessing (Nathan der Weise)

Tony Mechelynck

unread,
Sep 24, 2012, 9:51:05 PM9/24/12
to vim...@googlegroups.com
On 24/09/12 19:56, Christian Brabandt wrote:
> Hi Matthias!
>
> On Mo, 24 Sep 2012, Matthias Pitzl wrote:
>
>> Hi there!
>>
>> Is it somehow possible to do a :syn off only for one specific window?
>>
>> Thanks in advance!
>
> Yes, if you use :setl syntax=off

or just :setl syntax= (with nothing after the = sign)

If by any chance you had downloaded a syntax/off.vim in one of the
directory trees part of 'runtimepath', ":setl syntax=off" would apply it
to the current editfile.

> :syn off will turn off syntax highlighting globally.
>
> regards,
> Christian
>

Best regards,
Tony.
--
Money is the root of all evil, and man needs roots

Christian Brabandt

unread,
Sep 25, 2012, 2:20:13 AM9/25/12
to vim...@googlegroups.com, vim...@googlegroups.com
On Tue, September 25, 2012 03:51, Tony Mechelynck wrote:
> On 24/09/12 19:56, Christian Brabandt wrote:
>> On Mo, 24 Sep 2012, Matthias Pitzl wrote:
>>> Is it somehow possible to do a :syn off only for one specific window?
>> Yes, if you use :setl syntax=off
>
> or just :setl syntax= (with nothing after the = sign)
>
> If by any chance you had downloaded a syntax/off.vim in one of the
> directory trees part of 'runtimepath', ":setl syntax=off" would apply it
> to the current editfile.

Considering, that the advised method of disabling syntax highlighting
in the help is using :set syntax=OFF we should probably prevent loading a
syntax file with the name OFF and handle this in synload.vim (as it is
already done for the value 'ON')

Here is a patch, that does that (and additionally makes the check for
the syntax item ignore case):
--- syntax\synload.vim Tue Sep 25 08:09:53 2012
+++ syntax\synload.vim.new Tue Sep 25 08:09:43 2012
@@ -38,7 +38,7 @@
endif

let s = expand("<amatch>")
- if s == "ON"
+ if s ==? "ON"
" :set syntax=ON
if &filetype == ""
echohl ErrorMsg
@@ -46,6 +46,8 @@
echohl None
endif
let s = &filetype
+ elseif s ==? "OFF"
+ let s = ''
endif

if s != ""


regards,
Christian

Matthias Pitzl

unread,
Sep 25, 2012, 3:19:50 AM9/25/12
to vim...@googlegroups.com
On 09/24/2012 07:56 PM, Christian Brabandt wrote:
> Hi Matthias!
>
> On Mo, 24 Sep 2012, Matthias Pitzl wrote:
>
>> Hi there!
>>
>> Is it somehow possible to do a :syn off only for one specific window?
>>
>> Thanks in advance!
>
> Yes, if you use :setl syntax=off
> :syn off will turn off syntax highlighting globally.
>
> regards,
> Christian
>

Hi Christian,

Works like a charm! Thanks a lot!

-- Matthias

Tony Mechelynck

unread,
Sep 25, 2012, 8:23:57 AM9/25/12
to vim...@googlegroups.com, Christian Brabandt, vim...@googlegroups.com
Somehow :setl syn=ON (or even :setl syn=on) seems to set the syntax
highlighting according to the value of 'filetype', but :setl syn?
answers " syntax=ON" or " syntax=on" respectively. From what I see
above it sems to be the intended behaviour. Didn't know that.

As long as there is _no_ off.vim syntax script (and who would install a
syntax script of that name?), the behaviour for an "unknown" syntax is
to highlight everything like the Normal group anyway.


Best regards,
Tony.
--
Whistler's Law:
You never know who is right, but you always know who is in
charge.

Christian Brabandt

unread,
Sep 25, 2012, 8:57:54 AM9/25/12
to vim...@googlegroups.com, vim...@googlegroups.com
On Tue, September 25, 2012 14:23, Tony Mechelynck wrote:
> Somehow :setl syn=ON (or even :setl syn=on) seems to set the syntax
> highlighting according to the value of 'filetype', but :setl syn?
> answers " syntax=ON" or " syntax=on" respectively. From what I see
> above it sems to be the intended behaviour. Didn't know that.

I guess, that is what is meant by :h 'syntax':
,----
| Otherwise this option does not always reflect the current syntax (the
| b:current_syntax variable does).
`----

regards,
Christian

Reply all
Reply to author
Forward
0 new messages