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

Use of '*" for search

Expand Messages
  • Ken Roser
    I ve searched as much as I can and can t seem to find the solution for this. I want to use the * command to search for words in my file. The problem is that
    Message 1 of 3 , Mar 1, 2004
    • 0 Attachment
      I've searched as much as I can and can't seem to find the solution for
      this. I want to use the '*' command to search for words in my file.
      The problem is that the words have hyphens in them and vim breaks words
      at the hyphens. Is there a way for me to have '*' work this way. For
      example if I have the cursor on the letter t in the word
      'this-is-a-word', I want '*' to find 'this-is-a-word' instead of
      finding 'this'.

      Thanks.
    • Ilya Sher
      ... Hash: SHA1 ... for ... words ... For ... in particular ... Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
      Message 2 of 3 , Mar 1, 2004
      • 0 Attachment
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        Ken Roser wrote:
        | I've searched as much as I can and can't seem to find the solution
        for
        | this. I want to use the '*' command to search for words in my file.
        | The problem is that the words have hyphens in them and vim breaks
        words
        | at the hyphens. Is there a way for me to have '*' work this way.
        For
        | example if I have the cursor on the letter t in the word
        | 'this-is-a-word', I want '*' to find 'this-is-a-word' instead of
        | finding 'this'.
        |
        | Thanks.
        |
        |
        :help isk
        in particular
        :set iskeyword+=-
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.2.4 (GNU/Linux)
        Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

        iD8DBQFARCfxKQCqGJKGZm4RAiKAAKDvtg0zPvoEchF1Sm5cupXKpn+aBgCbBGM/
        I4ZQUG3SlEZ5PIBfTzTAnKw=
        =Vuvo
        -----END PGP SIGNATURE-----
      • David Fishburn
        Besides changing the iskeyword option, you can add the following to your vimrc file: You can visually select a region and hit * (or #) and it will search for
        Message 3 of 3 , Mar 3, 2004
        • 0 Attachment
          Besides changing the iskeyword option, you can add the following to your
          vimrc file:

          You can visually select a region and hit * (or #) and it will search for
          what you highlighted.
          Saves a lot of typing.

          Dave



          " Courtesy of Michael Naumann, Jürgen Krämer
          " Visually select text, then search for it
          if version >= 602
          " Here are two enhanced versions of these mappings which use VIM 6.2's
          " getregtype() function to determine whether the unnamed register
          contains
          " a characterwise, linewise or blockwise selection. After the search has

          " been executed, the register *and* its type can then be restored with
          " setreg().
          vnoremap <silent> * :<C-U>
          \let old_reg=getreg('"')<bar>
          \let old_regmode=getregtype('"')<cr>
          \gvy/<C-R><C-R>=substitute(substitute(
          \escape(@", '\\/.*$^~[]'), "\n$", "", ""),
          \"\n", '\\_[[:return:]]', "g")<cr><cr>
          \:call setreg('"', old_reg, old_regmode)<cr>
          vnoremap <silent> # :<C-U>
          \let old_reg=getreg('"')<bar>
          \let old_regmode=getregtype('"')<cr>
          \gvy?<C-R><C-R>=substitute(substitute(
          \escape(@", '\\/.*$^~[]'), "\n$", "", ""),
          \"\n", '\\_[[:return:]]', "g")<cr><cr>
          \:call setreg('"', old_reg, old_regmode)<cr>
          else
          " If you use both VIM 6.2 and older versions these mappings
          " should be defined depending on the current version.
          vnoremap <silent> * :<C-U>let old_reg=@"<cr>
          \gvy/<C-R><C-R>=substitute(substitute(
          \escape(@", '\\/.*$^~[]'), "\n$", "", ""),
          \"\n", '\\_[[:return:]]', "g")<cr><cr>
          \:let @"=old_reg<cr>
          vnoremap <silent> # :<C-U>let old_reg=@"<cr>
          \gvy?<C-R><C-R>=substitute(substitute(
          \escape(@", '\\/.*$^~[]'), "\n$", "", ""),
          \"\n", '\\_[[:return:]]', "g")<cr><cr>
          \:let @"=old_reg<cr>
          endif

          > -----Original Message-----
          > From: Ken Roser [mailto:kroser@...]
          > Sent: Tuesday, March 02, 2004 1:04 AM
          > To: vim@...
          > Subject: Use of '*" for search
          >
          >
          > I've searched as much as I can and can't seem to find the
          > solution for
          > this. I want to use the '*' command to search for words in my file.
          > The problem is that the words have hyphens in them and vim
          > breaks words
          > at the hyphens. Is there a way for me to have '*' work this
          > way. For
          > example if I have the cursor on the letter t in the word
          > 'this-is-a-word', I want '*' to find 'this-is-a-word' instead of
          > finding 'this'.
          >
          > Thanks.
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.