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

Re: Default syntax coloring

Expand Messages
  • Charles E. Campbell, Jr.
    ... Do you have syn on in your ? If so, what is the filetype, if any, before you manually set the highlighting? ie. :echo &ft Also, what s the
    Message 1 of 8 , Feb 1, 2006
    • 0 Attachment
      Michael Russo wrote:

      >9 times out of 10, I use VIM to view the source of an HTML page from Internet Explorer. I would like the syntax coloring to default to "HTML", or at the very least, I would like to not have to go to "Syntax" in the file menu, select "Show Filetypes in Menu" and then select "Syntax" again and then select "H" and then "HTML" and then "HTML" again. This sounds like a very simple thing to do, but I have not been able to do this. This is a nuisance, not an emergency, but it's been a nuisance for so long it feels like an emergency...
      >
      >

      Do you have "syn on" in your <.vimrc>?

      If so, what is the filetype, if any, before you manually set the
      highlighting?
      ie. :echo &ft

      Also, what's the file's suffix? (:echo expand("%"))

      I'm mostly a linux user, so I don't know how you're getting the html
      page source from Internet Explorer.

      Some other "good stuff" to have in your .vimrc:

      set nocp
      if version >= 600
      filetype plugin indent on
      endif

      Note -- that's .vimrc, not .gvimrc.

      Regards,
      Chip Campbell
    • A. J. Mechelynck
      ... One possibility is to have the line runtime vimrc_example.vim or source $VIMRUNTIME/vimrc_example.vim (which are more or less equivalent) near the top of
      Message 2 of 8 , Feb 1, 2006
      • 0 Attachment
        Charles E. Campbell, Jr. wrote:
        > Michael Russo wrote:
        >
        >> 9 times out of 10, I use VIM to view the source of an HTML page from
        >> Internet Explorer. I would like the syntax coloring to default to
        >> "HTML", or at the very least, I would like to not have to go to
        >> "Syntax" in the file menu, select "Show Filetypes in Menu" and then
        >> select "Syntax" again and then select "H" and then "HTML" and then
        >> "HTML" again. This sounds like a very simple thing to do, but I have
        >> not been able to do this. This is a nuisance, not an emergency, but
        >> it's been a nuisance for so long it feels like an emergency...
        >>
        >>
        >
        > Do you have "syn on" in your <.vimrc>?
        >
        > If so, what is the filetype, if any, before you manually set the
        > highlighting?
        > ie. :echo &ft
        >
        > Also, what's the file's suffix? (:echo expand("%"))
        >
        > I'm mostly a linux user, so I don't know how you're getting the html
        > page source from Internet Explorer.
        >
        > Some other "good stuff" to have in your .vimrc:
        >
        > set nocp
        > if version >= 600
        > filetype plugin indent on
        > endif
        > Note -- that's .vimrc, not .gvimrc.
        >
        > Regards,
        > Chip Campbell


        One possibility is to have the line

        runtime vimrc_example.vim
        or
        source $VIMRUNTIME/vimrc_example.vim

        (which are more or less equivalent) near the top of your vimrc. This
        will include a lot of useful settings (including "set nocompatible",
        "filetype plugin indent on" and "syntax on"). You can still override
        them by means of lines coming later in the vimrc (for instance, to keep
        filetype recognition and filetype plugins but not filetype-related
        indenting, add "filetpe indent off").


        Best regards,
        Tony.
      • David Fishburn
        ... I have been meaning to get to this one as well. You post pushed me along nicely. Normally I use Firefox to browse the web and view the source. But
        Message 3 of 8 , Feb 2, 2006
        • 0 Attachment
          > -----Original Message-----
          > From: Michael Russo [mailto:michaelrusso73@...]
          > Sent: Wednesday, February 01, 2006 4:03 PM
          > To: vim@...
          > Subject: Default syntax coloring
          >
          > Hi,
          >
          > 9 times out of 10, I use VIM to view the source of an HTML
          > page from Internet Explorer. I would like the syntax coloring
          > to default to "HTML", or at the very least, I would like to
          > not have to go to "Syntax" in the file menu, select "Show
          > Filetypes in Menu" and then select "Syntax" again and then
          > select "H" and then "HTML" and then "HTML" again. This
          > sounds like a very simple thing to do, but I have not been
          > able to do this. This is a nuisance, not an emergency, but
          > it's been a nuisance for so long it feels like an emergency.

          I have been meaning to get to this one as well. You post pushed me along
          nicely.

          Normally I use Firefox to browse the web and view the source.
          But occassionally I have to use IE, and when I choose View Source Vim starts
          up editing a file with a name like:

          C:\Documents and Settings\fishburn\Local Settings\Temporary Internet
          Files\Content.IE5\MV8BI5OJ\www.vim[1]

          Since it never ends in "html", Vim doesn't turn on the standard HTML
          filetype.

          So I put the following in my vimrc:
          " Automatically convert IE's view source files to the HTML filetype
          autocmd! BufEnter *
          \ if match(expand('%:p:h'), 'Content\.IE') > 0 |
          \ let &filetype = 'html' |
          \ endif

          So this checks the filename to see if it contains 'Content.IE', if so, it
          sets the filetype to HTML.

          That should do the trick for you.

          HTH,
          Dave

          --
          Do you use Vim to edit SQL?
          <Plug>
          Check the description of these plugins:
          dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
          Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
          SQLUtilities - Formatting SQL, generate - columns lists, procedures for
          databases (http://www.vim.org/scripts/script.php?script_id=492)
          sql.vim - SQL indent file for Sybase ASA and Oracle
          (http://www.vim.org/scripts/script.php?script_id=495)
          Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
          (http://www.vim.org/scripts/script.php?script_id=747)
          </Plug>
        • David Fishburn
          ... Actually, I guess the more appropriate location to do this is in: .vim/vimfiles/filetype.vim (*nix) c: vim vimfiles filetype.vim (Windows) And add the
          Message 4 of 8 , Feb 3, 2006
          • 0 Attachment
            > > 9 times out of 10, I use VIM to view the source of an HTML
            > page from
            > > Internet Explorer. I would like the syntax coloring to default to
            > > "HTML", or at the very least, I would like to not have to go to
            > > "Syntax" in the file menu, select "Show Filetypes in Menu" and then
            > > select "Syntax" again and then select "H" and then "HTML" and then
            > > "HTML" again. This sounds like a very simple thing to do,
            > but I have
            > > not been able to do this. This is a nuisance, not an emergency, but
            > > it's been a nuisance for so long it feels like an emergency.
            >
            > I have been meaning to get to this one as well. You post
            > pushed me along nicely.
            >
            > Normally I use Firefox to browse the web and view the source.
            > But occassionally I have to use IE, and when I choose View
            > Source Vim starts up editing a file with a name like:
            >
            > C:\Documents and Settings\fishburn\Local Settings\Temporary
            > Internet Files\Content.IE5\MV8BI5OJ\www.vim[1]
            >
            > Since it never ends in "html", Vim doesn't turn on the
            > standard HTML filetype.
            >
            > So I put the following in my vimrc:
            > " Automatically convert IE's view source files to the HTML
            > filetype autocmd! BufEnter *
            > \ if match(expand('%:p:h'), 'Content\.IE') > 0 |
            > \ let &filetype = 'html' |
            > \ endif
            >
            > So this checks the filename to see if it contains
            > 'Content.IE', if so, it sets the filetype to HTML.


            Actually, I guess the more "appropriate" location to do this is in:
            .vim/vimfiles/filetype.vim (*nix)
            c:\vim\vimfiles\filetype.vim (Windows)

            And add the following (at the bottom):
            " Automatically convert IE's view source files to the HTML filetype
            au BufNewFile,BufRead *
            \ if match(expand('%:p:h'), 'Content\.IE') > 0 |
            \ let &filetype = 'html' |
            \ endif

            Less clutter in your vimrc (mine is already very large) and that is the
            purpose of this file, to determine what to set the filetype to.

            Mike, I have tested this change and it works fine.

            Dave
          • A. J. Mechelynck
            David Fishburn wrote: [...] ... If we want to follow the conventions of the filetype.vim script, shouldn t that be au BufRead,BufNewFile */Content.IE?/* setf
            Message 5 of 8 , Feb 3, 2006
            • 0 Attachment
              David Fishburn wrote:
              [...]
              > Actually, I guess the more "appropriate" location to do this is in:
              > .vim/vimfiles/filetype.vim (*nix)
              > c:\vim\vimfiles\filetype.vim (Windows)
              >
              > And add the following (at the bottom):
              > " Automatically convert IE's view source files to the HTML filetype
              > au BufNewFile,BufRead *
              > \ if match(expand('%:p:h'), 'Content\.IE') > 0 |
              > \ let &filetype = 'html' |
              > \ endif

              If we want to follow the conventions of the filetype.vim script,
              shouldn't that be

              au BufRead,BufNewFile */Content.IE?/* setf html

              ? (See, among others, ":help autocmd-patterns" and ":help file-pattern"
              which follows it)

              >
              > Less clutter in your vimrc (mine is already very large) and that is the
              > purpose of this file, to determine what to set the filetype to.
              >
              > Mike, I have tested this change and it works fine.
              >
              > Dave


              Best regards,
              Tony.
            • David Fishburn
              ... Yes thanks Tony, that is even better. Dave
              Message 6 of 8 , Feb 3, 2006
              • 0 Attachment
                > > And add the following (at the bottom):
                > > " Automatically convert IE's view source files to the HTML filetype
                > > au BufNewFile,BufRead *
                > > \ if match(expand('%:p:h'), 'Content\.IE') > 0 |
                > > \ let &filetype = 'html' |
                > > \ endif
                >
                > If we want to follow the conventions of the filetype.vim
                > script, shouldn't that be
                >
                > au BufRead,BufNewFile */Content.IE?/* setf html

                Yes thanks Tony, that is even better.

                Dave
              Your message has been successfully submitted and would be delivered to recipients shortly.