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

Re: Syntax highlighting

Expand Messages
  • 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 1 of 6 , Jul 2 11:31 AM
    • 0 Attachment
      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 2 of 6 , Jan 2, 2007
      • 0 Attachment
        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 3 of 6 , Jan 2, 2007
        • 0 Attachment
          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.