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

highlighting text between marks

Expand Messages
  • googler
    I have two marks, say a and b. I want to highlight the text between (and including) a and b. I tried to use the match command like this ... I know accessing
    Message 1 of 7 , Aug 1, 2009
    • 0 Attachment
      I have two marks, say a and b. I want to highlight the text between
      (and including) a and b. I tried to use the match command like this
      :'a,'b match MyGrp /.*/
      I know accessing marks with ' (instead of `) will not be accurate to
      the resolution of the exact characters, but I was hoping to get at
      least the lines highlighted. But it doesn't work.

      How do I do this? It is best if it highlights only the portion of text
      bounded by the marks and not the entire line.

      BTW, does any plugin exist where I can select a part of text in visual
      mode (say using the mouse) and pressing some specific key will
      highlight this text?

      Thanks.

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Teemu Likonen
      ... --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For more information, visit
      Message 2 of 7 , Aug 1, 2009
      • 0 Attachment
        On 2009-08-01 00:25 (-0700), googler wrote:

        > I have two marks, say a and b. I want to highlight the text between
        > (and including) a and b. I tried to use the match command like this
        > :'a,'b match MyGrp /.*/

        Try this first:

        :help /\%'m

        For example:

        :match ErrorMsg /\%'a\_.*\%'b/

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • KKde
        ... Cool. I never know this is possible. But what is the purpose of this feature? Matching between sections can be achieved by line numbers Thanks, Sarath
        Message 3 of 7 , Aug 1, 2009
        • 0 Attachment
          >
          > Try this first:
          >
          >     :help /\%'m
          >
          > For example:
          >
          >     :match ErrorMsg /\%'a\_.*\%'b/

          Cool. I never know this is possible. But what is the purpose of this
          feature? Matching between sections can be achieved by line numbers

          Thanks,
          Sarath
          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • googler
          ... What do you mean by Matching between sections can be achieved by line numbers ? I guess even for matching using line numbers, a similar syntax is to be
          Message 4 of 7 , Aug 1, 2009
          • 0 Attachment
            On Aug 1, 12:56 pm, KKde <khekadestro...@...> wrote:
            > > Try this first:
            >
            > >     :help /\%'m
            >
            > > For example:
            >
            > >     :match ErrorMsg /\%'a\_.*\%'b/
            >
            > Cool. I never know this is possible. But what is the purpose of this
            > feature? Matching between sections can be achieved by line numbers
            >
            What do you mean by "Matching between sections can be achieved by line
            numbers"? I guess even for matching using line numbers, a similar
            syntax is to be used. For example, :match ErrorMsg /\%10l\_.*\%17l/
            (to highlight lines 10 to 17). But this will highlight entire lines
            and not a part of the beginning or end lines.

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • googler
            ... Hi, thanks for the reply. It did answer my question, but on second thoughts, I would actually like to use the line number and column number corresponding
            Message 5 of 7 , Aug 1, 2009
            • 0 Attachment
              On Aug 1, 6:46 am, Teemu Likonen <tliko...@...> wrote:
              > On 2009-08-01 00:25 (-0700), googler wrote:
              >
              > > I have two marks, say a and b. I want to highlight the text between
              > > (and including) a and b. I tried to use the match command like this
              > > :'a,'b match MyGrp /.*/
              >
              > Try this first:
              >
              >     :help /\%'m
              >
              > For example:
              >
              >     :match ErrorMsg /\%'a\_.*\%'b/

              Hi, thanks for the reply. It did answer my question, but on second
              thoughts, I would actually like to use the line number and column
              number corresponding to each mark inside the ':match' command. So my
              question is, given a mark (say `a, '<, etc), is it possible to get its
              line number and column number? I have to do this because the marks I
              use to define a match earlier might get redefined, in which case those
              highlights will be gone.

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Stahlman Family
              googler wrote: ... You might have a look at the Txtfmt plugin: http://www.vim.org/scripts/script.php?script_id=2208 http://www.freewebs.com/txtfmt It s a
              Message 6 of 7 , Aug 2, 2009
              • 0 Attachment
                googler wrote:
                ...snip...
                >
                > BTW, does any plugin exist where I can select a part of text in visual
                > mode (say using the mouse) and pressing some specific key will
                > highlight this text?

                You might have a look at the Txtfmt plugin:

                http://www.vim.org/scripts/script.php?script_id=2208
                http://www.freewebs.com/txtfmt

                It's a token-based highlighter, which allows you to highlight ranges of
                text with (configurable) colors and format attributes (e.g., bold,
                italic, underline, etc...). Version 2.0 (coming soon) supports
                background colors as well. There is a rich set of mappings for working
                with (e.g., inserting, jumping to, etc...) the tokens that begin and end
                regions. These tokens are hidden as whitespace. Version 2.0 also
                supports Vince Negri's 'conceal' patch, which permits the tokens to be
                hidden completely (i.e., made to occupy zero-width).

                Visual mode maps have not yet been implemented, but are in the todo list...

                Brett Stahlman

                >
                > Thanks.
                >
                > >
                >

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Tony Mechelynck
                ... However, be aware that those functions give the position at the time they are invoked. If you add or remove text before where the mark used to be, the line
                Message 7 of 7 , Aug 14, 2009
                • 0 Attachment
                  On 01/08/09 22:09, googler wrote:
                  >
                  >
                  >
                  > On Aug 1, 6:46 am, Teemu Likonen<tliko...@...> wrote:
                  >> On 2009-08-01 00:25 (-0700), googler wrote:
                  >>
                  >>> I have two marks, say a and b. I want to highlight the text between
                  >>> (and including) a and b. I tried to use the match command like this
                  >>> :'a,'b match MyGrp /.*/
                  >>
                  >> Try this first:
                  >>
                  >> :help /\%'m
                  >>
                  >> For example:
                  >>
                  >> :match ErrorMsg /\%'a\_.*\%'b/
                  >
                  > Hi, thanks for the reply. It did answer my question, but on second
                  > thoughts, I would actually like to use the line number and column
                  > number corresponding to each mark inside the ':match' command. So my
                  > question is, given a mark (say `a, '<, etc), is it possible to get its
                  > line number and column number? I have to do this because the marks I
                  > use to define a match earlier might get redefined, in which case those
                  > highlights will be gone.

                  See:
                  :help line()
                  :help col()
                  :help virtcol()

                  However, be aware that those functions give the position at the time
                  they are invoked. If you add or remove text before where the mark used
                  to be, the line & column numbers will become inexact. OTOH, as long as
                  you don't use the same mark for something else, it will "move" with its
                  text and remain correct even if you do some edit before the mark's position.


                  Best regards,
                  Tony.
                  --
                  "I'm fed up to the ears with old men dreaming up wars for young men to
                  die in."
                  -- George McGovern

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                Your message has been successfully submitted and would be delivered to recipients shortly.