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

Changed behaviour of search in 6.4?

Expand Messages
  • Anthony Campbell
    I m finding that if I do a search for any character in a buffer, that character continues to be highlighted in all subsequent buffers that I start. This seems
    Message 1 of 8 , Nov 8, 2005
    • 0 Attachment
      I'm finding that if I do a search for any character in a buffer, that
      character continues to be highlighted in all subsequent buffers that I
      start.

      This seems to be a new development; I don't think it happened
      previously. Is it a bug or a feature and can it be turned off?

      Anthony


      --
      Anthony Campbell - ac@...
      Microsoft-free zone - Using Linux Gnu-Debian
      http://www.acampbell.org.uk (blog, book reviews,
      on-line books and sceptical articles)
    • James Vega
      ... Vim 6.x has always done this if you have the hlsearch option set. You can use the :nohl command to stop the current highlighting. Another option would
      Message 2 of 8 , Nov 8, 2005
      • 0 Attachment
        On Tue, Nov 08, 2005 at 10:23:23AM +0000, Anthony Campbell wrote:
        > I'm finding that if I do a search for any character in a buffer, that
        > character continues to be highlighted in all subsequent buffers that I
        > start.
        >
        > This seems to be a new development; I don't think it happened
        > previously. Is it a bug or a feature and can it be turned off?

        Vim 6.x has always done this if you have the 'hlsearch' option set. You
        can use the :nohl command to stop the current highlighting. Another
        option would be to set 'nohlsearch' and enable 'incsearch' so that the
        search item is highlighed as you type it.

        James
        --
        GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>
      • Strange
        ... It s a feature and it seems vim has this feature for a long time.
        Message 3 of 8 , Nov 8, 2005
        • 0 Attachment
          Anthony Campbell wrote:
          > I'm finding that if I do a search for any character in a buffer, that
          > character continues to be highlighted in all subsequent buffers that I
          > start.
          >
          > This seems to be a new development; I don't think it happened
          > previously. Is it a bug or a feature and can it be turned off?
          >
          > Anthony
          >
          >
          It's a feature and it seems vim has this feature for a long time.
          :nohl could disable the keyword highlighting.
        • Anthony Campbell
          ... Thanks for this clarification. I ve been using 6.x for some time but I didn t notice it previously; it must have slipped by me somewhere along the line.
          Message 4 of 8 , Nov 8, 2005
          • 0 Attachment
            On 08 Nov 2005, James Vega wrote:
            > On Tue, Nov 08, 2005 at 10:23:23AM +0000, Anthony Campbell wrote:
            > > I'm finding that if I do a search for any character in a buffer, that
            > > character continues to be highlighted in all subsequent buffers that I
            > > start.
            > >
            > > This seems to be a new development; I don't think it happened
            > > previously. Is it a bug or a feature and can it be turned off?
            >
            > Vim 6.x has always done this if you have the 'hlsearch' option set. You
            > can use the :nohl command to stop the current highlighting. Another
            > option would be to set 'nohlsearch' and enable 'incsearch' so that the
            > search item is highlighed as you type it.
            >
            > James
            > --
            > GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>


            Thanks for this clarification. I've been using 6.x for some time but I
            didn't notice it previously; it must have slipped by me somewhere along
            the line.

            Anthony


            --
            Anthony Campbell - ac@...
            Microsoft-free zone - Using Linux Gnu-Debian
            http://www.acampbell.org.uk (blog, book reviews,
            on-line books and sceptical articles)
          • Gareth Oakes
            Kind-of on the same topic, I just added two mappings to my .vimrc: nmap :exec match IncSearch / .expand( ). / imap :exec match
            Message 5 of 8 , Nov 14, 2005
            • 0 Attachment
              Kind-of on the same topic, I just added two mappings to my .vimrc:

              nmap <A-m> :exec 'match IncSearch /'.expand('<cword>').'/'<CR>
              imap <A-m> :exec 'match IncSearch /'.expand('<cword>').'/'<CR>

              This allows me to press Alt-m to highlight the word under the cursor, in
              my IncSearch colour. The "match" command is buffer-specific, and
              independent of the search highlighting, so it won't interfere with
              highlighting of characters in other buffers.

              Caveats to my method:

              1) I'm not 100% sure about using the expand() function, but it was the
              easiest way I found to grab the word under the cursor.

              2) I haven't wrapped the regex in \<\> so it will match the highlight
              keyword inside of other words, which is fine for what I need.

              3) If you don't have enough space in your command area, then you get a
              "Hit ENTER ... " prompt from Vim when you press Alt-m.

              Cheers,
              Gareth

              Anthony Campbell wrote:
              > I'm finding that if I do a search for any character in a buffer, that
              > character continues to be highlighted in all subsequent buffers that I
              > start.
              >
              > This seems to be a new development; I don't think it happened
              > previously. Is it a bug or a feature and can it be turned off?
              >
              > Anthony
              >
              >
            • Gareth Oakes
              Hi there, ... Thanks for the tip, I had tried that one previously but was not happy with the result. I ve ended up going with :set laststatus=2, which also
              Message 6 of 8 , Nov 15, 2005
              • 0 Attachment
                Hi there,

                Keith W. Roberts wrote:
                >> 1) I'm not 100% sure about using the expand() function, but
                >>it was the
                >>easiest way I found to grab the word under the cursor.
                >>
                >> 2) I haven't wrapped the regex in \<\> so it will match the
                >>highlight keyword inside of other words, which is fine for what I
                >>need.
                >>
                >> 3) If you don't have enough space in your command area,
                >>then you get a
                >>"Hit ENTER ... " prompt from Vim when you press Alt-m.
                >
                > Re the new post: :set ch=2 solves that.
                >
                > -Keith

                Thanks for the tip, I had tried that one previously but was not happy
                with the result. I've ended up going with :set laststatus=2, which also
                gets rid of the "Hit ENTER ... " prompt but gives me something more
                useful in the extra screen line.

                BTW, I would be interested if anyone could tell me the "correct" way to
                grab the current word, instead of using the function "expand('<cword>')".

                Cheers,
                Gareth
              • Jürgen Krämer
                Hi, ... in a mapping you can use or (the latter one inserts the WORD under the cursor). Regards, Jürgen -- Jürgen Krämer
                Message 7 of 8 , Nov 15, 2005
                • 0 Attachment
                  Hi,

                  Gareth Oakes wrote:
                  >
                  > BTW, I would be interested if anyone could tell me the "correct" way to
                  > grab the current word, instead of using the function "expand('<cword>')".

                  in a mapping you can use <c-r><c-w> or <c-r><c-a> (the latter one
                  inserts the WORD under the cursor).

                  Regards,
                  Jürgen

                  --
                  Jürgen Krämer Softwareentwicklung
                  HABEL GmbH & Co. KG mailto:jkr@...
                  Hinteres Öschle 2 Tel: +49 / 74 61 / 93 53 - 15
                  78604 Rietheim-Weilheim Fax: +49 / 74 61 / 93 53 - 99
                • Gareth Oakes
                  ... Of course! *slaps forehead* As always, you re an oracle of wisdom, Jürgen :) I m just about getting my brain into the Vim way of things now, thanks for
                  Message 8 of 8 , Nov 15, 2005
                  • 0 Attachment
                    Jürgen Krämer wrote:
                    > Hi,
                    >
                    > Gareth Oakes wrote:
                    >
                    >>BTW, I would be interested if anyone could tell me the "correct" way to
                    >>grab the current word, instead of using the function "expand('<cword>')".
                    >
                    >
                    > in a mapping you can use <c-r><c-w> or <c-r><c-a> (the latter one
                    > inserts the WORD under the cursor).

                    Of course! *slaps forehead*

                    As always, you're an oracle of wisdom, Jürgen :) I'm just about getting
                    my brain into the Vim way of things now, thanks for the help.

                    For those readers playing at home, the current set of mappings is now:

                    nmap <A-m> :match IncSearch /<c-r><c-w>/<CR>
                    imap <A-m> :match IncSearch /<c-r><c-w>/<CR>
                    nmap <A-n> :match none<CR>
                    imap <A-n> :match none<CR>


                    Cheers,
                    Gareth
                  Your message has been successfully submitted and would be delivered to recipients shortly.