Putting syntax sync fromstart in ~/.vimrc

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Putting syntax sync fromstart in ~/.vimrc

Guy Rutenberg

Hi,

I've tried putting

:syntax sync from start

In my ~/.vimrc file but it seems it doesn't have any effect and I have
to issue the command manually for every file I open. Does anyone have
an idea how can I make the syntax highlighting evaluate the whole file
automatically?


Regards,
Guy
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Putting syntax sync fromstart in ~/.vimrc

Badmagic

Guy Rutenberg wrote:

> Hi,
>
> I've tried putting
>
> :syntax sync from start
>
> In my ~/.vimrc file but it seems it doesn't have any effect and I have
> to issue the command manually for every file I open. Does anyone have
> an idea how can I make the syntax highlighting evaluate the whole file
> automatically?
>
>
> Regards,
> Guy
> Hi,

I'm using Vim version 7.1.145 and all I've got in my ~/.vimrc file is:

syntax on

and all of my files are completely syntax highlighted (if that's correct
English) - *.c, *.html, *.conf, *.vimrc etc. All of them.

Don't know if this helps?

Cheers,
Steve (BM)





--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

RE: Putting syntax sync fromstart in ~/.vimrc

Liang Chen-5

Does your VIM support HIGHLIGHT SYNTAX ,make sure of that by typing
version ,and find out .
If it does, just put 'syntax on' in your .vim script,if not ,get a
version supporting
syntax.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of badmagic
Sent: Friday, June 06, 2008 5:04 PM
To: [hidden email]
Subject: Re: Putting syntax sync fromstart in ~/.vimrc


Guy Rutenberg wrote:

> Hi,
>
> I've tried putting
>
> :syntax sync from start
>
> In my ~/.vimrc file but it seems it doesn't have any effect and I have
> to issue the command manually for every file I open. Does anyone have
> an idea how can I make the syntax highlighting evaluate the whole file
> automatically?
>
>
> Regards,
> Guy
> Hi,

I'm using Vim version 7.1.145 and all I've got in my ~/.vimrc file is:

syntax on

and all of my files are completely syntax highlighted (if that's correct

English) - *.c, *.html, *.conf, *.vimrc etc. All of them.

Don't know if this helps?

Cheers,
Steve (BM)







--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Putting syntax sync fromstart in ~/.vimrc

Guy Rutenberg

Hi,

Thanks for the quick reply.

My vim has syntax highlighting turned on and the syntax highlighting
works. The problem is that vim by default doesn't inspect the whole
file when it highlights the code, but only a given number of lines
before the current top line. While this works great for certain
filetypes (like C) it can result in incorrect highlighting when
editing a very long file that incorporates multiple highlighting
schemes, like HTML.

The best solution I've fount for it is you do
:syntax sync fromstart
which tells vim to always inspect the file from the start. The problem
is that vim ignores this command in the vimrc so I have to do it
manually when I open each file.

I hope I made my problem a bit clearer.

Thanks,

Guy

On Jun 6, 12:06 pm, "Liang Chen" <[hidden email]> wrote:

> Does your VIM support HIGHLIGHT SYNTAX ,make sure of that by typing
> version ,and find out .
> If it does, just put 'syntax on' in your .vim script,if not ,get a
> version supporting
> syntax.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
>
> Behalf Of badmagic
> Sent: Friday, June 06, 2008 5:04 PM
> To: [hidden email]
> Subject: Re: Putting syntax sync fromstart in ~/.vimrc
>
> Guy Rutenberg wrote:
> > Hi,
>
> > I've tried putting
>
> > :syntax sync from start
>
> > In my ~/.vimrc file but it seems it doesn't have any effect and I have
> > to issue the command manually for every file I open. Does anyone have
> > an idea how can I make the syntax highlighting evaluate the whole file
> > automatically?
>
> > Regards,
> > Guy
> > Hi,
>
> I'm using Vim version 7.1.145 and all I've got in my ~/.vimrc file is:
>
> syntax on
>
> and all of my files are completely syntax highlighted (if that's correct
>
> English) - *.c, *.html, *.conf, *.vimrc etc. All of them.
>
> Don't know if this helps?
>
> Cheers,
> Steve (BM)
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Putting syntax sync fromstart in ~/.vimrc

Tony Mechelynck

On 06/06/08 13:35, Guy Rutenberg wrote:

> Hi,
>
> Thanks for the quick reply.
>
> My vim has syntax highlighting turned on and the syntax highlighting
> works. The problem is that vim by default doesn't inspect the whole
> file when it highlights the code, but only a given number of lines
> before the current top line. While this works great for certain
> filetypes (like C) it can result in incorrect highlighting when
> editing a very long file that incorporates multiple highlighting
> schemes, like HTML.
>
> The best solution I've fount for it is you do
> :syntax sync fromstart
> which tells vim to always inspect the file from the start. The problem
> is that vim ignores this command in the vimrc so I have to do it
> manually when I open each file.
>
> I hope I made my problem a bit clearer.
>
> Thanks,
>
> Guy

I think each syntax scripts sets syn sync for the files it highlights.

You might want top place your syn sync command in some after-script, e.g.
(Unix) $HOME/.vim/after/syntax/html.vim
(Windows) $HOME/vimfiles/after/syntax/html.vim

Create the directories if they don't exist yet.

Best regards,
Tony.
--
"I am not an Economist.  I am an honest man!"
                -- Paul McCracken

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Putting syntax sync fromstart in ~/.vimrc

Ben Schmidt
In reply to this post by Guy Rutenberg

Guy Rutenberg wrote:

> Hi,
>
> I've tried putting
>
> :syntax sync from start
>
> In my ~/.vimrc file but it seems it doesn't have any effect and I have
> to issue the command manually for every file I open. Does anyone have
> an idea how can I make the syntax highlighting evaluate the whole file
> automatically?

When each file loads, it loads the syntax for that file, which usually
contains sync commands which override the earlier one in your vimrc.

One solution is to use after files for each filetype to override this by
creating files for the different filetypes you edit where you want this
different behaviour, e.g. for c, you create ~/.vim/after/syntax/c.vim
and put your command in that (create necessary parent directories).

Another is using an autocommand to run the command automatically after
the syntax changes

:au Syntax * syntax sync fromstart

This command must be in your vimrc after the syntax highlighting is
turned on, or it will happen before the syntax change still!

By replacing the * with some other pattern you can make it apply to only
specific syntaxes if you desire, too.

Also note that 'fromstart' should be one word, I believe.

Ben.



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Putting syntax sync fromstart in ~/.vimrc

Badmagic
In reply to this post by Liang Chen-5

Liang Chen wrote:

> Does your VIM support HIGHLIGHT SYNTAX ,make sure of that by typing
> version ,and find out .
> If it does, just put 'syntax on' in your .vim script,if not ,get a
> version supporting
> syntax.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of badmagic
> Sent: Friday, June 06, 2008 5:04 PM
> To: [hidden email]
> Subject: Re: Putting syntax sync fromstart in ~/.vimrc
>
>
> Guy Rutenberg wrote:
>> Hi,
>>
>> I've tried putting
>>
>> :syntax sync from start
>>
>> In my ~/.vimrc file but it seems it doesn't have any effect and I have
>> to issue the command manually for every file I open. Does anyone have
>> an idea how can I make the syntax highlighting evaluate the whole file
>> automatically?
>>
>>
>> Regards,
>> Guy
>> Hi,
>
> I'm using Vim version 7.1.145 and all I've got in my ~/.vimrc file is:
>
> syntax on
>
> and all of my files are completely syntax highlighted (if that's correct
>
> English) - *.c, *.html, *.conf, *.vimrc etc. All of them.
>
> Don't know if this helps?
>
> Cheers,
> Steve (BM)
>
>
>
>
>
>
>
> >
Thanks, Liang

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Putting syntax sync fromstart in ~/.vimrc

Petr Mach
In reply to this post by Ben Schmidt
> Another is using an autocommand to run the command automatically after
> the syntax changes
>
> :au Syntax * syntax sync fromstart
>
> This command must be in your vimrc after the syntax highlighting is
> turned on, or it will happen before the syntax change still!

I'm trying it, but this is do not work for me. Syntax is showed incorrectly still. Syntax is repaired after manual comand :synatx sync fromstart.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Putting syntax sync fromstart in ~/.vimrc

Christian Brabandt

On Mo, 14 Mai 2018, Petr Mach wrote:

> > Another is using an autocommand to run the command automatically after
> > the syntax changes
> >
> > :au Syntax * syntax sync fromstart
> >
> > This command must be in your vimrc after the syntax highlighting is
> > turned on, or it will happen before the syntax change still!
>
> I'm trying it, but this is do not work for me. Syntax is showed incorrectly still. Syntax is repaired after manual comand :synatx sync fromstart.

You are probably experiencing it because the syntax file uses some
complex regular expressions and then it times out. You might want to
increase the 'redrawtime' setting.

In any case, you should always mention the filetype/syntax in use and
possibly post the :syntime report when you are experiencing this issue.

Best,
Christian
--
Ausführungsbestimmungen sind Erklärungen zu den Erklärungen, mit denen
man eine Erklärung erklärt.
                -- Abraham Lincoln

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.