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

Re: ok, new question on search

Expand Messages
  • Albie Janse van Rensburg
    ... The search register can be overwritten by setting @/ to . This then clears your search properly . For my purposes, I have the following mapping in my
    Message 1 of 9 , Apr 2, 2007
    • 0 Attachment
      Gene Kwiecinski wrote:
      >> when i do a search like /text
      >> it highlights all of the matches and i can use n and N to navigate.
      >> how do i turn the highlighting off when i am done?
      >>
      >
      > Need to keep the pattern in memory? If not, "/zzz" will do it, assuming
      > you don't have "zzz" anywhere else in your file, of course.
      >
      > Can fiddle with ":set nohls" and whatnot, but for me, it's just easier
      > to search for nothing to turn off highlighting of the just-searched-for
      > text.
      >
      > Then, of course, you'd have to ":set hls" to turn it back on again.
      > Lotta typing, big pain, 'swhy I don't do that, and just search for
      > gibberish instead if I want to unhighlight what I was just looking for.
      >
      The search register can be overwritten by setting @/ to ''. This then
      clears your search "properly".

      For my purposes, I have the following mapping in my vimrc:

      nnoremap <silent> <M-/> :set @/=''<CR>

      so pressing alt-/ then clears my search.

      --
      Albie Janse van Rensburg

      It is only by risking our persons from one hour to another that we live
      at all. And often enough our faith beforehand in an uncertified result
      is the only thing that makes the result come true. -- William James
    • shawn bright
      cool enough, i guess i could map something to ... thanks sk
      Message 2 of 9 , Apr 2, 2007
      • 0 Attachment
        cool enough, i guess i could map something to
        :/impossible_to_find_text or something
        thanks
        sk

        On 4/2/07, Gene Kwiecinski <gkwiecinski@...> wrote:
        > >when i do a search like /text
        > >it highlights all of the matches and i can use n and N to navigate.
        > >how do i turn the highlighting off when i am done?
        >
        > Need to keep the pattern in memory? If not, "/zzz" will do it, assuming
        > you don't have "zzz" anywhere else in your file, of course.
        >
        > Can fiddle with ":set nohls" and whatnot, but for me, it's just easier
        > to search for nothing to turn off highlighting of the just-searched-for
        > text.
        >
        > Then, of course, you'd have to ":set hls" to turn it back on again.
        > Lotta typing, big pain, 'swhy I don't do that, and just search for
        > gibberish instead if I want to unhighlight what I was just looking for.
        >
      • Gene Kwiecinski
        ... assuming ... Yeah, but all those - and - stretches on the kb make my fingers hurt... :D
        Message 3 of 9 , Apr 2, 2007
        • 0 Attachment
          >>Need to keep the pattern in memory? If not, "/zzz" will do it,
          assuming
          >>you don't have "zzz" anywhere else in your file, of course.

          >The search register can be overwritten by setting @/ to ''. This then
          >clears your search "properly".
          >For my purposes, I have the following mapping in my vimrc:
          >nnoremap <silent> <M-/> :set @/=''<CR>
          >so pressing alt-/ then clears my search.

          Yeah, but all those <shift>- and <alt>- stretches on the kb make my
          fingers hurt... :D
        • Guido Van Hoecke
          ... Now, as soon as you hit the enter key, the higlight is turned off. Is a very straigthforward and easy way of turning off the current highlight, without
          Message 4 of 9 , Apr 2, 2007
          • 0 Attachment
            shawn bright said on 02-04-07 17:56:
            > lo there,
            > when i do a search like /text
            > it highlights all of the matches and i can use n and N to navigate.
            > how do i turn the highlighting off when i am done?

            You could put following mapping in your.vimrc:

            :nnoremap <silent> <CR> :nohlsearch<CR>

            Now, as soon as you hit the enter key, the higlight is turned off.

            Is a very straigthforward and easy way of turning off the current highlight, without changing your settings at all.

            HTH, Guido.

            --
            http://vanhoecke.org ... and go2 places!
          • Chad Gulley
            i have a mapping that will toggle search highlighting on and off. you may find it useful. map :set hlsearch! -- chad
            Message 5 of 9 , Apr 2, 2007
            • 0 Attachment
              i have a mapping that will toggle search highlighting on and off. you may find it useful.
              map <F3> :set hlsearch! <CR>

              --
              chad



              On Mon, Apr 02, 2007 at 12:43:07PM -0400, Jean-Rene David wrote:
              > * shawn bright [2007.04.02 12:00]:
              > > when i do a search like /text
              > > it highlights all of the matches and i can use n
              > > and N to navigate. how do i turn the
              > > highlighting off when i am done?
              >
              > There's a command to do exactly that:
              >
              > :nohlsearch
              >
              > This will turn off highlighting for the current
              > search. Highlighting will come back for the next
              > search.
              >
              > Note that this is different from the 'hlsearch'
              > option, whose effects are permanent.
              >
              > Of course you can map this:
              >
              > :map <F2> :nohlsearch<CR>
              >
              > --
              > JR
            • A.J.Mechelynck
              ... (with no set ) clears search highlighting until next search. If the 4 characters are to much for you, map it to a key, e.g. ... Best regards, Tony. --
              Message 6 of 9 , Apr 2, 2007
              • 0 Attachment
                Gene Kwiecinski wrote:
                >>> Need to keep the pattern in memory? If not, "/zzz" will do it,
                > assuming
                >>> you don't have "zzz" anywhere else in your file, of course.
                >
                >> The search register can be overwritten by setting @/ to ''. This then
                >> clears your search "properly".
                >> For my purposes, I have the following mapping in my vimrc:
                >> nnoremap <silent> <M-/> :set @/=''<CR>
                >> so pressing alt-/ then clears my search.
                >
                > Yeah, but all those <shift>- and <alt>- stretches on the kb make my
                > fingers hurt... :D
                >

                :noh

                (with no "set") clears search highlighting until next search. If the 4
                characters are to much for you, map it to a key, e.g.

                :map <F12> :noh<CR>
                :imap <F12> <C-O>:noh<CR>


                Best regards,
                Tony.
                --
                What the large print giveth, the small print taketh away.
              Your message has been successfully submitted and would be delivered to recipients shortly.