On Jul 17, 9:22 am, Linda W <[email protected]> wrote:
> 01234567890123456789012345678901234567890123456789012345678901234567890123456789
> After changing tab stops and "expandtabs", one can retab to "reformat"
> the text according to the new tabsettings. There is also the "gq" option
> that will reformat text according to changed text options.
>
> I was wondering if there was a way to do the same according to a change
> of the 'syntax'.
>
> I read in a file of txt that has 1-64K line of text of of what I
> discovered was 'css-code'. I set syntax=css -- and it dutifully went
> through and colored the syntax, but it's still all one line. There are,
> also, several close curly brackets highlighted in red, though I don't
> know if these are real errors or just some confusion of the syntax
> coloring because of the lack of new lines.
>
> Nevertheless, is there anything like a 'resyn' option or is the
> only thing to rely on would be 'gq' and to manually search for, or find
> and external program for the given syntax, and manually setup up its
> options each time you change syntax.
>
I'm afraid you'll probably need to break the line up on your own, or
using an external tool. A simple regex should break it up for you
though. :s#[{};]#\0\r#g should be a good start for valid CSS code.
Then you can visually select the entire area of interest and hit = to
apply the filetype indent rule if you've enabled that feature. That
should do a fairly decent job of cleaning things up.
> I'm not even sure how well that would work -- as one problem with
> 'syn' is there are many cases where the syntax isn't constant within
> one file. I suppose for those sections one could simply leave them
> unformatted (unless they were strongly related (like CSS in HTML).
> But parsing syntax of different languages embedded within other
> language files would be a neat option (will talk about that in another
> email to not confuse this issue) -- which is the desire to
> reformat a section of text according to new syntax rules.
>
For the *highlighting*, see our current featured tip at the wiki:
http://vim.wikia.com/wiki/Different_syntax_highlighting_within_regions_of_a_file
Many syntax files actually do this already.
For indentation, you can modify the indent script, perhaps something
like what is contained near the bottom here:
http://vim.wikia.com/wiki/User:Ipkiss/Using_vim_to_edit_tips
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---