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

Syntax highlighting

Expand Messages
  • Bohdan Vlasyuk
    Hi ! Is it possible to get following functionality with Vim syntax files: Suppose I have some pattern, e.g.: ({ ) s + ( w + ) s + (: ) s + ( w + ) s +
    Message 1 of 6 , May 21, 2001
      Hi !

      Is it possible to get following functionality with Vim syntax files:

      Suppose I have some pattern, e.g.:

      \({\)
      \s\+
      \(\w\+\)
      \s\+
      \(:\)
      \s\+
      \(\w\+\)
      \s\+
      \(}\)

      You see, there are five groups enclosed in brackets. What I'd like to
      get is to hightligh all there groups with defferent colors. I.e. I
      want to highligh ONLY strings that match this pattern, and I want to
      define color for each \(\) group. How is it possible with Vim in
      general ?? (may be it's possible with this simple patterm,
      however, I'd like to seea any general solution is possible).

      The reason to use such style of matching is that it's quite natural
      and compact.

      Thanks.
      --
      Bye.
    • Alan G. Isaac
      ... and see the example in ... Alan Isaac
      Message 2 of 6 , May 21, 2001
        On Mon, 21 May 2001, Bohdan Vlasyuk wrote:
        > You see, there are five groups enclosed in brackets. What I'd like to
        > get is to hightligh all there groups with defferent colors. I.e. I
        > want to highligh ONLY strings that match this pattern, and I want to
        > define color for each \(\) group.


        :h syn-contained
        and see the example in
        :h syn-matchgroup

        Alan Isaac
      • Tim Musson
        Hey all, Just reinstalled VIM after a rebuild of my computer this past December. I am back at doing some coding, and don t like other editors to code with...
        Message 3 of 6 , Jul 2, 2001
          Hey all,

          Just reinstalled VIM after a rebuild of my computer this past
          December. I am back at doing some coding, and don't like other
          editors to code with... <g>

          I was hoping to get some help getting my Syntax Highlighting
          working again.

          I am running Win32 and put my vim.exe in the c:\perl\bin directory.

          In the same dir as the .exe I have my _vimrc that looks like this:
          set nocompatible
          "source $VIMRUNTIME/vimrc_example.vim
          behave xterm
          set selectmode=mouse

          " I set these --tim
          set number
          syntax on

          The _vimrc file I am using is not much different from the old
          install (and yes, I did try the old one).

          Also in the .exe dir is the "syntax" dir that *does* have
          syntax.vim, synload.vim, and perl.vim (trying to get the
          highlighting for perl .pl files).

          Any suggestions?

          Thanks in advance for any help!

          --
          Tim@...
          Using The Bat! eMail v1.53d
          Windows NT 5.0.2195 (Service Pack 1)
          Smile, it's the second best thing you can do with your lips.
        • Benji Fisher
          ... First, figure out whether the problem is with finding the vimrc file or with syntax. (I suspect it is the latter.) My favorite method is to add ... to my
          Message 4 of 6 , Jul 2, 2001
            Tim Musson wrote:
            >
            > Hey all,
            >
            > Just reinstalled VIM after a rebuild of my computer this past
            > December. I am back at doing some coding, and don't like other
            > editors to code with... <g>
            >
            > I was hoping to get some help getting my Syntax Highlighting
            > working again.
            >
            > I am running Win32 and put my vim.exe in the c:\perl\bin directory.
            >
            > In the same dir as the .exe I have my _vimrc that looks like this:
            > set nocompatible
            > "source $VIMRUNTIME/vimrc_example.vim
            > behave xterm
            > set selectmode=mouse
            >
            > " I set these --tim
            > set number
            > syntax on
            >
            > The _vimrc file I am using is not much different from the old
            > install (and yes, I did try the old one).
            >
            > Also in the .exe dir is the "syntax" dir that *does* have
            > syntax.vim, synload.vim, and perl.vim (trying to get the
            > highlighting for perl .pl files).
            >
            > Any suggestions?

            First, figure out whether the problem is with finding the vimrc file or
            with syntax. (I suspect it is the latter.) My favorite method is to add

            :let foo = <today's date>

            to my vimrc file. Then quit, start up vim, and try

            :echo foo

            to see whether the vimrc file has been loaded.

            If your vimrc file is being sourced, I think the problem is your
            directory structure, and the runtime files. Under $VIMRUNTIME (which I think
            will be the same exe dir for you) you should have (at least) filetype.vim as
            well as the syntax/ subdirectory. I would also make sure to include the doc/
            subdirectory. To avoid cluttering up the exe directory, I would put all of
            this under a runtime/ or vim57/ subdirectory, and let Vim figure out that that
            is where $VIMRUNTIME should point.

            :help $VIM
            :help $VIMRUNTIME
            :help syntax-loading

            HTH --Benji Fisher
          • cupaxe
            Is there a way to have different (see below) syntax highlighting for different portions of a file? What I am interested in knowing is whether there exists a
            Message 5 of 6 , Jan 2, 2007
              Is there a way to have different (see below) syntax highlighting for
              different portions of a file?

              What I am interested in knowing is whether there exists a meta file
              format (say multisyn) which highlights different portions of a file
              with syntax corresponding to that portion.

              For instance, let the file multisyn.cat be the following-

              >> Start of multisyn.cat
              +++++++++++++++++++++++++++
              #!/usr/bin/perl
              print "Hello world\n";
              foreach $i ( 1 .. 10 ){
              print $i,"\n";
              }
              +++++++++++++++++++++++++++
              #!/bin/tcsh
              set hello = "world";
              echo $hello
              +++++++++++++++++++++++++++
              >> End of multisyn.cat


              What I would like is that each portion of multisyn.cat be highlighted
              with a different syntax corresponding to that portions file marked by
              the #!/usr/... indicator. For instance, I would like the first portion
              to be highlighted using the perl syntax and the second portion be
              highlighted using the tcsh syntax.

              If there doesn't exist one, would it be possible to create a new file
              type called say multisyn and write a syntax which does the job? Is it
              possible?

              Thanks,
              Krishna
            • A.J.Mechelynck
              ... Some languages can include text written in other languages, and the corresponding syntax script takes that into account: for instance, you might want to
              Message 6 of 6 , Jan 2, 2007
                cupaxe wrote:
                > Is there a way to have different (see below) syntax highlighting for
                > different portions of a file?
                >
                > What I am interested in knowing is whether there exists a meta file
                > format (say multisyn) which highlights different portions of a file
                > with syntax corresponding to that portion.
                >
                > For instance, let the file multisyn.cat be the following-
                >
                >>> Start of multisyn.cat
                > +++++++++++++++++++++++++++
                > #!/usr/bin/perl
                > print "Hello world\n";
                > foreach $i ( 1 .. 10 ){
                > print $i,"\n";
                > }
                > +++++++++++++++++++++++++++
                > #!/bin/tcsh
                > set hello = "world";
                > echo $hello
                > +++++++++++++++++++++++++++
                >>> End of multisyn.cat
                >
                >
                > What I would like is that each portion of multisyn.cat be highlighted
                > with a different syntax corresponding to that portions file marked by
                > the #!/usr/... indicator. For instance, I would like the first portion
                > to be highlighted using the perl syntax and the second portion be
                > highlighted using the tcsh syntax.
                >
                > If there doesn't exist one, would it be possible to create a new file
                > type called say multisyn and write a syntax which does the job? Is it
                > possible?
                >
                > Thanks,
                > Krishna
                >

                Some languages can include text written in other languages, and the
                corresponding syntax script takes that into account: for instance, you might
                want to look into $VIMRUNTIME/syntax/html.vim to see how it caters for CSS
                style sheets, VBS scripts and JS scripts embedded into HTML pages; or into
                $VIMRUNTIME/syntax/vim.vim which accepts here-documents in perl, python, ruby,
                tcl or scheme, embedded into Vim scripts.


                Best regards,
                Tony.
              Your message has been successfully submitted and would be delivered to recipients shortly.