Loading ...
Sorry, an error occurred while loading the content.

Re: Syntax Highlighting

Expand Messages
  • Tim Johnson
    Hi Benji: Thanks for the reply. Here are responses to your ... This returns the following: -- Auto Commands Syntax Cpp so $VIMRUNTIME/syntax/cpp.vim -- and
    Message 1 of 17 , Jan 2, 2001
    • 0 Attachment
      Hi Benji:
      Thanks for the reply. Here are responses to your
      suggestions:
      > guess is that you have accidentally erased the autocommands that load >the
      > syntax for cpp files. Try
      >
      > :au Syntax cpp
      This returns the following:
      -- Auto Commands
      Syntax
      Cpp so $VIMRUNTIME/syntax/cpp.vim
      -- and cpp.vim exists at /usr/share/vim/vim56/syntax

      > There should be similar autocommands for loading the syntax files. If I
      > am right, the cpp autocommands have been erased, and you should look
      > through your [g]vimrc files for an :au! that erases them.
      >
      > In case I am wrong, here are some things to try to help diagnose the
      > problem. What happens when you edit a cpp file and
      >
      > :set ft
      filetype=
      > :set syntax
      syntax=
      > :set ft=cpp
      " syntax highlighting is enabled
      > :e!
      " syntaxing highlighting is disabled
      >
      > ...? You can also try
      >
      > :set verbose=8
      " no change that I can see
      >
      > (or start vim with the -v flag, I think).
      " the only change is that background for gvim is
      " same as the console
      " below is .gvimrc segment
      if has("autocmd")
      autocmd BufRead *.txt set tw=78
      augroup cprog
      "remove all cprog autocommands
      "au!
      "when ........
      autocmd FileType * set formatoptions=tcql nocindent comments&
      autocmd FileType c,cpp
      setformatoptions=croqlcomments=sr:/*,mb:*,el:*/,://
      augroup END

      "originally the au! statement was not commented. Commenting it
      " out didn't seem to change the situation

      Thanks for the advice so far! :)
      Tim
    • Benji Fisher
      ... [snip] ... [snip] ... OK, my first guess was wrong, but my follow-up questions were on target. Maybe I should have suggested :set verbose=9 though: this
      Message 2 of 17 , Jan 2, 2001
      • 0 Attachment
        Tim Johnson wrote:
        >
        > Hi Benji:
        > Thanks for the reply. Here are responses to your
        > suggestions:
        > > guess is that you have accidentally erased the autocommands that load >the
        > > syntax for cpp files. Try
        > >
        > > :au Syntax cpp
        > This returns the following:
        > -- Auto Commands
        > Syntax
        > Cpp so $VIMRUNTIME/syntax/cpp.vim
        > -- and cpp.vim exists at /usr/share/vim/vim56/syntax
        >
        [snip]
        > >
        > > In case I am wrong, here are some things to try to help diagnose the
        > > problem. What happens when you edit a cpp file and
        > >
        > > :set ft
        > filetype=
        > > :set syntax
        > syntax=
        > > :set ft=cpp
        > " syntax highlighting is enabled
        [snip]
        > " below is .gvimrc segment
        > if has("autocmd")
        > autocmd BufRead *.txt set tw=78
        > augroup cprog
        > "remove all cprog autocommands
        > "au!
        > "when ........
        > autocmd FileType * set formatoptions=tcql nocindent comments&
        > autocmd FileType c,cpp
        > setformatoptions=croqlcomments=sr:/*,mb:*,el:*/,://
        > augroup END
        >
        > "originally the au! statement was not commented. Commenting it
        > " out didn't seem to change the situation
        >
        > Thanks for the advice so far! :)
        > Tim

        OK, my first guess was wrong, but my follow-up questions were on
        target. Maybe I should have suggested :set verbose=9 though: this will
        give information on what autocommands are being executed. You can also
        use the -V (not -v) flag when starting vim.

        The problem is that 'filetype' (and hence also 'syntax') is not being
        set. Try

        :au BufNewFile *.cpp

        This should tell you about an autocommand defined in
        $VIMRUNTIME/filetype.vim, which sets the file type. If this autocommand
        does not exist, it was not defined or it was erased. If the autocommand
        for *.mak is there then the one for *.cpp was probably erased, so you can
        figure this out. If the autocommand for *.cpp IS there then it is being
        over-ridden by some other autocommand, which you will have to seek out and
        destroy.

        If it is still not cleat what is happening, use the 'verbose' option
        and pay attention to all the information it gives you.

        Do not forget to restore your gvimrc file.

        HTH --Benji Fisher
      • Dima Yamkovoy
        Is there any way to have a syn match that works for all file types? I tried putting syn match ... in my vimrc, but whenever I edit a file with syntax
        Message 3 of 17 , Oct 12, 2003
        • 0 Attachment
          Is there any way to have a "syn match" that works for all file types?
          I tried putting "syn match ..." in my vimrc, but whenever I edit a file
          with syntax highlighting, my match gets eaten by that filetype's
          highlighting.

          What I'm really trying to do is to show what characters are after 80
          columns. I'm trying to:
          syn match PastEighty /.\%>81/

          Is there any better way to do this? Is there a way to have it adapt to
          my textwidth?


          __________________________________
          Do you Yahoo!?
          The New Yahoo! Shopping - with improved product search
          http://shopping.yahoo.com
        • John Aldridge
          ... I have plugins that do syntax highlighting on all files; so yes, you should be able to put meaningful syn match items in your vimrc (though I prefer
          Message 4 of 17 , Oct 12, 2003
          • 0 Attachment
            At 13:33 10-12-2003, Dima Yamkovoy wrote:

            >Is there any way to have a "syn match" that works for all file types?
            >I tried putting "syn match ..." in my vimrc, but whenever I edit a file
            >with syntax highlighting, my match gets eaten by that filetype's
            >highlighting.
            >
            >What I'm really trying to do is to show what characters are after 80
            >columns. I'm trying to:
            >syn match PastEighty /.\%>81/
            >
            >Is there any better way to do this? Is there a way to have it adapt to
            >my textwidth?

            I have plugins that do syntax highlighting on all files; so yes, you
            should be able to put meaningful syn match items in your vimrc
            (though I prefer plugins to keep things organized).

            However, the functionality your describing doesn't seem to fit
            your syn match example. I was able (in gvim 6.2 for windows)
            to do this:

            :syn match Folded /\(.\{80}\)\@<=.*/

            This highlights all characters to the right of the 80th column.
            The example you've provided highlights every character below the
            80th line. Of course, that won't show up on files with less
            than 81 characters.



            ~
            ~
            ~
            "John R. Aldridge, Jr."
          • Gary Johnson
            ... I don t know if it s any better, but I use :match for this, and have these lines in my .vimrc: highlight RightMargin term=reverse ctermbg=12 guifg=White
            Message 5 of 17 , Oct 12, 2003
            • 0 Attachment
              On 2003-10-12, Dima Yamkovoy <yamkovoyd@...> wrote:
              > Is there any way to have a "syn match" that works for all file types?
              > I tried putting "syn match ..." in my vimrc, but whenever I edit a file
              > with syntax highlighting, my match gets eaten by that filetype's
              > highlighting.
              >
              > What I'm really trying to do is to show what characters are after 80
              > columns. I'm trying to:
              > syn match PastEighty /.\%>81/
              >
              > Is there any better way to do this? Is there a way to have it adapt to
              > my textwidth?

              I don't know if it's any better, but I use :match for this, and have
              these lines in my .vimrc:

              highlight RightMargin term=reverse ctermbg=12 guifg=White guibg=Blue

              au BufNewFile,BufRead * match
              au BufNewFile,BufRead *.c,*.h exec 'match RightMargin /\%>' . &textwidth . 'v.\+/'

              HTH,
              Gary

              --
              Gary Johnson | Agilent Technologies
              garyjohn@... | Wireless Division
              | Spokane, Washington, USA
            • Dima Yamkovoy
              ... Actually, that s great, thanks. As a temporary solution that I almost liked, I set up a function to toggle a mode where it highlights everything after 80
              Message 6 of 17 , Oct 12, 2003
              • 0 Attachment
                > I don't know if it's any better, but I use :match for this, and have
                > these lines in my .vimrc: <snip>

                Actually, that's great, thanks.
                As a temporary solution that I almost liked, I set up a function to
                toggle a "mode" where it highlights everything after 80 (my regex
                wasn't the problem, I just copied it wrong). To do this, it did a "syn
                clear" then set up its own highlighting. To switch back, it did
                another clear, followed by a reset. Not the most elegant solution but
                it worked. I like the :match idea better, though.


                __________________________________
                Do you Yahoo!?
                The New Yahoo! Shopping - with improved product search
                http://shopping.yahoo.com
              • Curtis Badke
                Good Day! I am having trouble making syntax highlighting work on my fresh Gentoo installation on a laptop. I am running kernel 2.6.3, aterm, and TERM=rxvt
                Message 7 of 17 , Feb 28, 2004
                • 0 Attachment
                  Good Day!

                  I am having trouble making syntax highlighting work on my fresh Gentoo
                  installation on a laptop.

                  I am running kernel 2.6.3, aterm, and TERM=rxvt

                  Whenever I enable syntax highlighting, instead of having keywords change
                  colour they get a string prepended to them.

                  Example:

                  #include<stdio.h>

                  becomes

                  *dm#include&dm<stdio.h>


                  I don't understand what is happening here because as far as I can tell my
                  configuration matches my working desktop computer except that I have the
                  newer kernel now.

                  Any ideas?

                  Thanks.
                • Alejandro Lopez-Valencia
                  ... Aren t you trying to peg a square block into a round hole? Do you have an rxvt entry in your terminfo database? Is aterm compatible with rxvt s (a modified
                  Message 8 of 17 , Feb 28, 2004
                  • 0 Attachment
                    Curtis Badke broke the silence of shunyata and uttered:

                    >
                    > I am running kernel 2.6.3, aterm, and TERM=rxvt
                    >
                    > Any ideas?

                    Aren't you trying to peg a square block into a round hole? Do you have
                    an rxvt entry in your terminfo database? Is aterm compatible with rxvt's
                    (a modified xterm, which usually sets term(7) as xterm) terminal
                    capabilities as defined in the terminfo database? I sincerely doubt it
                    in both counts.

                    Read term(5), term(7), terminfo(5), aterm(1), rxvt(1) and xterm(1) for a
                    start... And to remove the off-topic and make it relevant in this list,
                    ":h 'term'" ":h termcap" and "h term.txt" by all means :-)
                  • Curtis Badke
                    Thanks for the advice. I changed my TERM to xterm and that seems to have fixed the problem. The curious thing about this is that I have had other systems
                    Message 9 of 17 , Feb 28, 2004
                    • 0 Attachment
                      Thanks for the advice. I changed my TERM to xterm and that seems to have
                      fixed the problem. The curious thing about this is that I have had other
                      systems running perfectly with rxvt.

                      Oh well. Thanks again.


                      >Curtis Badke broke the silence of shunyata and uttered:
                      >
                      >>
                      >> I am running kernel 2.6.3, aterm, and TERM=rxvt
                      >>
                      >> Any ideas?
                      >
                      >Aren't you trying to peg a square block into a round hole? Do you have
                      >an rxvt entry in your terminfo database? Is aterm compatible with rxvt's
                      >(a modified xterm, which usually sets term(7) as xterm) terminal
                      >capabilities as defined in the terminfo database? I sincerely doubt it
                      >in both counts.
                      >
                      >Read term(5), term(7), terminfo(5), aterm(1), rxvt(1) and xterm(1) for a
                      >start... And to remove the off-topic and make it relevant in this list,
                      >":h 'term'" ":h termcap" and "h term.txt" by all means :-)
                    • Alejandro Lopez-Valencia
                      ... Most distro-based RXVTs are compiled with the option to force $TERM to something meaningful, usually xterm. You can see that if you examine the output of
                      Message 10 of 17 , Feb 29, 2004
                      • 0 Attachment
                        Curtis Badke broke the silence of shunyata and uttered:

                        > Thanks for the advice. I changed my TERM to xterm and that seems to
                        > have fixed the problem. The curious thing about this is that I have
                        > had other systems running perfectly with rxvt.
                        >

                        Most distro-based RXVTs are compiled with the option to force $TERM to
                        something meaningful, usually xterm. You can see that if you examine the
                        output of the version command, but with Gentoo, you are on your own. :-)
                      • Tony Mechelynck
                        ... 2 methods: - write your own colorscheme: more cumbersome, maybe, but neater and more flexible in the long run; and you can change colorschemes on the fly
                        Message 11 of 17 , Aug 4, 2007
                        • 0 Attachment
                          STEVE KUNDZALA wrote:
                          >
                          > I'd like to change the syntax highlighting for masm.vim, to be specific,
                          > masmOpcode & masmDirective from brown to black (uncolored). I did it a
                          > couple of years ago for 6.2, but I installed 7.1 and now I can't remember
                          > how I did it. Senility setting in!

                          2 methods:

                          - write your own colorscheme: more cumbersome, maybe, but neater and more
                          flexible in the long run; and you can change colorschemes "on the fly" without
                          restarting Vim.

                          - add ":hi" commands to your vimrc. Sounds simpler at first, but any changes
                          usually require restarting Vim.

                          See
                          :help :colorscheme
                          :help :hi

                          In this case you could write in either location

                          hi clear masmOpcode
                          hi clear masmDirective
                          and maybe then
                          hi link masmOpcode Normal
                          hi link masmDirective Normal

                          As food for thought, I'm appending my own "almost-default" colorscheme.
                          Simpler than most, so it should be rather easy to understand. Any groups which
                          aren't mentioned, are left at their default.

                          Notes:
                          1. A few groups (User1, User2, etc;) pertain to my nondefault 'statusline'
                          option (set in the vimrc, not in this colorscheme)
                          2. Just for fun, I included an autocommand to change the status line
                          background colour after 'updatetime' milliseconds of inaction.


                          Best regards,
                          Tony.
                          --
                          You may be recognized soon. Hide.


                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_use" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • STEVE KUNDZALA
                          Thanks Tony, I appreciate your help. For some reason NOTHING, NOTHING, NOTHING is working right with this 7.1 installation. I think I made a BIG mistake
                          Message 12 of 17 , Aug 4, 2007
                          • 0 Attachment
                            Thanks Tony, I appreciate your help. For some reason NOTHING, NOTHING,
                            NOTHING is working right with this 7.1 installation. I think I made a BIG
                            mistake upgrading. I should have left well enough alone, 6.2 was working
                            fine.
                            I added the "hi clear" lines you suggested to my vimrc and EVERYTHING shows
                            in black. Now when I enter :hi to display the assigned colors I don't see
                            the masm lines for example: "masmRegister xxx links to Special" , instead
                            I see asm lines.
                            I uninstalled/reinstalled for the 4th time, this time using C:\Vim instead
                            of C:\Program Files\Vim and still "opens with" can't be set to gvim.


                            > [Original Message]
                            > From: Tony Mechelynck <antoine.mechelynck@...>
                            > To: <vim_use@...>
                            > Date: 8/4/2007 12:16:57 PM
                            > Subject: Re: Syntax Highlighting
                            >
                            > STEVE KUNDZALA wrote:
                            > >
                            > > I'd like to change the syntax highlighting for masm.vim, to be specific,
                            > > masmOpcode & masmDirective from brown to black (uncolored). I did it a
                            > > couple of years ago for 6.2, but I installed 7.1 and now I can't
                            remember
                            > > how I did it. Senility setting in!
                            >
                            > 2 methods:
                            >
                            > - write your own colorscheme: more cumbersome, maybe, but neater and more
                            > flexible in the long run; and you can change colorschemes "on the fly"
                            without
                            > restarting Vim.
                            >
                            > - add ":hi" commands to your vimrc. Sounds simpler at first, but any
                            changes
                            > usually require restarting Vim.
                            >
                            > See
                            > :help :colorscheme
                            > :help :hi
                            >
                            > In this case you could write in either location
                            >
                            > hi clear masmOpcode
                            > hi clear masmDirective
                            > and maybe then
                            > hi link masmOpcode Normal
                            > hi link masmDirective Normal
                            >
                            > As food for thought, I'm appending my own "almost-default" colorscheme.
                            > Simpler than most, so it should be rather easy to understand. Any groups
                            which
                            > aren't mentioned, are left at their default.
                            >




                            --~--~---------~--~----~------------~-------~--~----~
                            You received this message from the "vim_use" maillist.
                            For more information, visit http://www.vim.org/maillist.php
                            -~----------~----~----~----~------~----~------~--~---
                          • ANDY KENNEDY
                            In the kconfig.vim file, there exists the following: syn keyword kconfigPreProc source nextgroup=kconfigPath skipwhite Later, there is: syn
                            Message 13 of 17 , Jan 17, 2013
                            • 0 Attachment
                              In the kconfig.vim file, there exists the following:

                              syn keyword kconfigPreProc source
                              \ nextgroup=kconfigPath
                              \ skipwhite

                              Later, there is:

                              syn match kconfigPath '"[^"\\]*\%(\\.[^"\\]*\)*"\|\S\+'
                              \ contained

                              which appears to match something like:

                              source "path/to/myfile"

                              however, it also seems to match

                              source path/to/myfile

                              which has caused me issues in the past. To that end, I want to do
                              something like what lilo.conf has in it where I can set
                              "source path/to/myfile" as Error text so I can clearly see what my
                              problem is.

                              I attempted to do something like:

                              syn match kconfigPreProcError source
                              \ nextgroup=kconfigPathError
                              \ skipwhite

                              syn match kconfigPathError '[^"]*.*$'

                              then later

                              hi def link kconfigPreProcError Error

                              But this didn't do what I expected.

                              Please tell me where I've gone wrong.

                              Thanks!
                              Andy

                              --
                              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
                            • Andy Wokula
                              ... This should give you E402: Garbage after pattern: source nextgroup=kconfigPathError skipwhite E475: Invalid argument: kconfigPreProcError source
                              Message 14 of 17 , Jan 18, 2013
                              • 0 Attachment
                                Am 17.01.2013 23:31, schrieb Andy Kennedy:
                                > In the kconfig.vim file, there exists the following:
                                >
                                > syn keyword kconfigPreProc source
                                > \ nextgroup=kconfigPath
                                > \ skipwhite
                                >
                                > Later, there is:
                                >
                                > syn match kconfigPath '"[^"\\]*\%(\\.[^"\\]*\)*"\|\S\+'
                                > \ contained
                                >
                                > which appears to match something like:
                                >
                                > source "path/to/myfile"
                                >
                                > however, it also seems to match
                                >
                                > source path/to/myfile
                                >
                                > which has caused me issues in the past. To that end, I want to do
                                > something like what lilo.conf has in it where I can set
                                > "source path/to/myfile" as Error text so I can clearly see what my
                                > problem is.
                                >
                                > I attempted to do something like:
                                >
                                > syn match kconfigPreProcError source
                                > \ nextgroup=kconfigPathError
                                > \ skipwhite

                                This should give you
                                E402: Garbage after pattern: source nextgroup=kconfigPathError skipwhite
                                E475: Invalid argument: kconfigPreProcError source nextgroup=kconfigPathError skipwhite

                                > syn match kconfigPathError '[^"]*.*$'
                                >
                                > then later
                                >
                                > hi def link kconfigPreProcError Error
                                >
                                > But this didn't do what I expected.
                                >
                                > Please tell me where I've gone wrong.
                                >
                                > Thanks!
                                > Andy

                                Try the following:

                                ~/.vim/after/syntax/kconfig.vim
                                #v+

                                syn clear kconfigPreProc
                                syn keyword kconfigPreProc source nextgroup=kconfigPath,kconfigPathError skipwhite

                                syn match kconfigPathError '[^" \t].*$' contained

                                hi def link kconfigPathError Error

                                #v-

                                --
                                Andy

                                --
                                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
                              • ANDY KENNEDY
                                ... Probably did. I guess I need to spend more time with :help syn-define. ... Cool! Thanks! I had to make a slight modification to what you put up there:
                                Message 15 of 17 , Jan 18, 2013
                                • 0 Attachment
                                  > Am 17.01.2013 23:31, schrieb Andy Kennedy:
                                  > > In the kconfig.vim file, there exists the following:
                                  > >
                                  > > syn keyword kconfigPreProc source
                                  > > \ nextgroup=kconfigPath
                                  > > \ skipwhite
                                  > >
                                  > > Later, there is:
                                  > >
                                  > > syn match kconfigPath '"[^"\\]*\%(\\.[^"\\]*\)*"\|\S\+'
                                  > > \ contained
                                  > >
                                  > > which appears to match something like:
                                  > >
                                  > > source "path/to/myfile"
                                  > >
                                  > > however, it also seems to match
                                  > >
                                  > > source path/to/myfile
                                  > >
                                  > > which has caused me issues in the past. To that end, I want to do
                                  > > something like what lilo.conf has in it where I can set
                                  > > "source path/to/myfile" as Error text so I can clearly see what my
                                  > > problem is.
                                  > >
                                  > > I attempted to do something like:
                                  > >
                                  > > syn match kconfigPreProcError source
                                  > > \ nextgroup=kconfigPathError
                                  > > \ skipwhite
                                  >
                                  > This should give you
                                  > E402: Garbage after pattern: source nextgroup=kconfigPathError skipwhite
                                  > E475: Invalid argument: kconfigPreProcError source nextgroup=kconfigPathError skipwhite

                                  Probably did. I guess I need to spend more time with :help syn-define.

                                  >
                                  > > syn match kconfigPathError '[^"]*.*$'
                                  > >
                                  > > then later
                                  > >
                                  > > hi def link kconfigPreProcError Error
                                  > >
                                  > > But this didn't do what I expected.
                                  > >
                                  > > Please tell me where I've gone wrong.
                                  > >
                                  > > Thanks!
                                  > > Andy
                                  >
                                  > Try the following:
                                  >
                                  > ~/.vim/after/syntax/kconfig.vim
                                  > #v+
                                  >
                                  > syn clear kconfigPreProc
                                  > syn keyword kconfigPreProc source nextgroup=kconfigPath,kconfigPathError skipwhite
                                  >
                                  > syn match kconfigPathError '[^" \t].*$' contained
                                  >
                                  > hi def link kconfigPathError Error
                                  >

                                  Cool! Thanks! I had to make a slight modification to what you put up
                                  there:

                                  syn match kconfigPathError '\s*[^"].*$' contained

                                  Otherwise, the obvious space prior to the path matches and the string is
                                  accepted. I want it to fail for anything not quoted. So, the
                                  modification is to allow any whitespace then look for anything not `"'.
                                  But that really helped. I am super grateful!

                                  Thanks again!
                                  Andy

                                  > #v-
                                  >
                                  > --
                                  > Andy
                                  >
                                  > --
                                  > 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 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
                                Your message has been successfully submitted and would be delivered to recipients shortly.