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

highlighting tabbed text

Expand Messages
  • Michael Naumann
    Is there a way to highlight a sequence of non-tabs followed by a sequence of tabs (/^[^ t] + t +/) differently from the next such sequence? For example in the
    Message 1 of 6 , Apr 30 4:18 PM
    • 0 Attachment
      Is there a way to highlight a sequence of non-tabs followed by a sequence
      of tabs (/^[^\t]\+\t\+/) differently from the next such sequence?

      For example in the line
      a\tb\t\tc\td

      I want
      "a\t" to be color1,
      "b\t\t" to be color2 and
      "c\t" to be color3 (or probably color1 again)

      Is this even possible?

      Michael
    • Gerald Lai
      ... You could check out Mark.vim http://www.vim.org/scripts/script.php?script_id=1238 HTH. -- Gerald
      Message 2 of 6 , Apr 30 10:04 PM
      • 0 Attachment
        On Mon, 1 May 2006, Michael Naumann wrote:

        > Is there a way to highlight a sequence of non-tabs followed by a sequence
        > of tabs (/^[^\t]\+\t\+/) differently from the next such sequence?
        >
        > For example in the line
        > a\tb\t\tc\td
        >
        > I want
        > "a\t" to be color1,
        > "b\t\t" to be color2 and
        > "c\t" to be color3 (or probably color1 again)
        >
        > Is this even possible?

        You could check out Mark.vim

        http://www.vim.org/scripts/script.php?script_id=1238

        HTH.
        --
        Gerald
      • Michael Naumann
        ... Nice script, indeed. Still I do not see how it can help me with my problem. Michael
        Message 3 of 6 , May 1, 2006
        • 0 Attachment
          On Monday 01 May 2006 07:04, Gerald Lai wrote:
          > On Mon, 1 May 2006, Michael Naumann wrote:
          >
          > > Is there a way to highlight a sequence of non-tabs followed by a sequence
          > > of tabs (/^[^\t]\+\t\+/) differently from the next such sequence?
          > >
          > > For example in the line
          > > a\tb\t\tc\td
          > >
          > > I want
          > > "a\t" to be color1,
          > > "b\t\t" to be color2 and
          > > "c\t" to be color3 (or probably color1 again)
          > >
          > > Is this even possible?
          >
          > You could check out Mark.vim
          >
          > http://www.vim.org/scripts/script.php?script_id=1238
          >
          > HTH.
          > --
          > Gerald
          >
          >

          Nice script, indeed.
          Still I do not see how it can help me with my problem.

          Michael
        • Yakov Lerner
          ... Yes this is possible using custom syntax highlighting. The commands below do what dou ask for. syn clear syn match Field1 /^[^ t] + t +/ nextgroup=Field2
          Message 4 of 6 , May 1, 2006
          • 0 Attachment
            On 5/1/06, Michael Naumann <michael@...> wrote:
            > Is there a way to highlight a sequence of non-tabs followed by a sequence
            > of tabs (/^[^\t]\+\t\+/) differently from the next such sequence?
            >
            > For example in the line
            > a\tb\t\tc\td
            >
            > I want
            > "a\t" to be color1,
            > "b\t\t" to be color2 and
            > "c\t" to be color3 (or probably color1 again)

            Yes this is possible using custom syntax highlighting.
            The commands below do what dou ask for.

            syn clear
            syn match Field1 /^[^\t]\+\t\+/ nextgroup=Field2
            syn match Field2 /[^\t]\+\t*/ nextgroup=Field3 contained
            syn match Field3 /[^\t]\+\t*/ nextgroup=Field2 contained
            hi link Field1 Constant
            hi link Field2 Operator
            hi link Field3 Type

            However it removes all other syntax highlighting.
            If you want it to work together with other syntax, you have to
            figure it for yourself.

            Yakov
          • Michael Naumann
            ... Brilliant, exactly what I was looking for. The nextgroup and the contained are the wise stuff here. Thanx a lot Michael
            Message 5 of 6 , May 1, 2006
            • 0 Attachment
              On Monday 01 May 2006 15:24, Yakov Lerner wrote:
              > On 5/1/06, Michael Naumann <michael@...> wrote:
              > > Is there a way to highlight a sequence of non-tabs followed by a sequence
              > > of tabs (/^[^\t]\+\t\+/) differently from the next such sequence?
              > >
              > > For example in the line
              > > a\tb\t\tc\td
              > >
              > > I want
              > > "a\t" to be color1,
              > > "b\t\t" to be color2 and
              > > "c\t" to be color3 (or probably color1 again)
              >
              > Yes this is possible using custom syntax highlighting.
              > The commands below do what dou ask for.
              >
              > syn clear
              > syn match Field1 /^[^\t]\+\t\+/ nextgroup=Field2
              > syn match Field2 /[^\t]\+\t*/ nextgroup=Field3 contained
              > syn match Field3 /[^\t]\+\t*/ nextgroup=Field2 contained
              > hi link Field1 Constant
              > hi link Field2 Operator
              > hi link Field3 Type
              >
              > However it removes all other syntax highlighting.
              > If you want it to work together with other syntax, you have to
              > figure it for yourself.
              >
              > Yakov
              >
              >

              Brilliant, exactly what I was looking for.
              The nextgroup and the contained are the wise stuff here.

              Thanx a lot

              Michael
            • Gerald Lai
              ... Mark.vim allows you to enter regular expressions. After installing mark.vim, do this 1. Type r and you ll get a @ prompt. 2. Enter
              Message 6 of 6 , May 1, 2006
              • 0 Attachment
                On Mon, 1 May 2006, Michael Naumann wrote:

                > On Monday 01 May 2006 07:04, Gerald Lai wrote:
                >> On Mon, 1 May 2006, Michael Naumann wrote:
                >>
                >>> Is there a way to highlight a sequence of non-tabs followed by a sequence
                >>> of tabs (/^[^\t]\+\t\+/) differently from the next such sequence?
                >>>
                >>> For example in the line
                >>> a\tb\t\tc\td
                >>>
                >>> I want
                >>> "a\t" to be color1,
                >>> "b\t\t" to be color2 and
                >>> "c\t" to be color3 (or probably color1 again)
                >>>
                >>> Is this even possible?
                >>
                >> You could check out Mark.vim
                >>
                >> http://www.vim.org/scripts/script.php?script_id=1238
                >>
                >> HTH.
                >> --
                >> Gerald
                >>
                >>
                >
                > Nice script, indeed.
                > Still I do not see how it can help me with my problem.

                Mark.vim allows you to enter regular expressions.

                After installing mark.vim, do this

                1. Type "\r" and you'll get a "@" prompt.
                2. Enter "^\%([^\t]\+\t\+\)\{1}" without quotes.

                3. Type "\r" and you'll get a "@" prompt.
                4. Enter "^\%([^\t]\+\t\+\)\{2}" without quotes.

                5. Type "\r" and you'll get a "@" prompt.
                6. Enter "^\%([^\t]\+\t\+\)\{3}" without quotes.

                Repeat as necessary, with numbers in ascending order.
                Could be as easy as typing "\r", followed by the Up arrow key, and
                changing the number count.

                If you wish to get rid of the highlightings, position the Normal cursor
                _not_ on the highlight, and hit "\n".

                HTH :)
                --
                Gerald
              Your message has been successfully submitted and would be delivered to recipients shortly.