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

highlight lines longer than 80 chars for a specific file types.

Expand Messages
  • Reuven Sayag
    Hi, I would like to highlight lines that are longer then 80 chars. ... the problem is that I only want to do that for cpp and h files, to set if for 100 for
    Message 1 of 4 , Sep 4, 2010
    • 0 Attachment
      Hi,
      I would like to highlight lines that are longer then 80 chars.
      I use:
      :match ErrorMsg '\%>80v.\+'
      the problem is that I only want to do that for cpp and h files, to set
      if for 100 for java and to unset it for any other type.
      Anyone knows how this can be done?

      --
      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
    • bill lam
      ... try (untest): au FileType cpp match ErrorMsg % 80v. + au FileType java match ErrorMsg % 100v. + -- regards,
      Message 2 of 4 , Sep 4, 2010
      • 0 Attachment
        Сбт, 04 Сен 2010, Reuven Sayag писал(а):
        > Hi,
        > I would like to highlight lines that are longer then 80 chars.
        > I use:
        > :match ErrorMsg '\%>80v.\+'
        > the problem is that I only want to do that for cpp and h files, to set
        > if for 100 for java and to unset it for any other type.
        > Anyone knows how this can be done?

        try (untest):

        au FileType cpp match ErrorMsg '\%>80v.\+'
        au FileType java match ErrorMsg '\%>100v.\+'

        --
        regards,
        ====================================================
        GPG key 1024D/4434BAB3 2008-08-24
        gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

        --
        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
      • Vivek Bhat
        This thing works for me. I am a COBOL developer and have to take care of columns. Is there away to ignore comments even if they cross the specified column?
        Message 3 of 4 , Sep 5, 2010
        • 0 Attachment
          This thing works for me. I am a COBOL developer and have to take care of columns. Is there away to ignore comments even if they cross the specified column?

          Thanks
          Vivek Bhat


          On Sun, Sep 5, 2010 at 4:47 AM, bill lam <cbill.lam@...> wrote:
          Сбт, 04 Сен 2010, Reuven Sayag писал(а):
          > Hi,
          > I would like to highlight lines that are longer then 80 chars.
          > I use:
          > :match ErrorMsg '\%>80v.\+'
          > the problem is that I only want to do that for cpp and h files, to set
          > if for 100 for java and to unset it for any other type.
          > Anyone knows how this can be done?

          try (untest):

          au FileType cpp       match ErrorMsg '\%>80v.\+'
          au FileType java      match ErrorMsg '\%>100v.\+'

          --
          regards,
          ====================================================
          GPG key 1024D/4434BAB3 2008-08-24
          gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

          --
          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
        • Ben Fritz
          ... This will almost work, except that matches are window-local. So loading another buffer of a different filetype into the same window will not clear the
          Message 4 of 4 , Sep 7, 2010
          • 0 Attachment
            On Sep 4, 6:17 pm, bill lam <cbill....@...> wrote:
            >
            > try (untest):
            >
            > au FileType cpp       match ErrorMsg '\%>80v.\+'
            > au FileType java      match ErrorMsg '\%>100v.\+'
            >

            This will almost work, except that matches are window-local. So
            loading another buffer of a different filetype into the same window
            will not clear the highlight, and additionally loading the same buffer
            in a new window will not add the file type.

            In Vim 7.2 I had a setup that would call a function on WinEnter as
            well as FileType (or maybe BufWinEnter?) to clear/add the appropriate
            highlighting. Some of my methods are captured in the following tips:

            http://vim.wikia.com/wiki/Highlight_long_lines
            http://vim.wikia.com/wiki/Detect_window_creation_with_WinEnter

            However, in Vim 7.3, I found all this unneccessary with the addition
            of the 'colorcolumn' option. I highly reccommend upgrading to version
            7.3 and using this option instead of trying to get the long-line
            highlight working.

            --
            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.