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

Normal Mod `*` on Keywords with `?`

Expand Messages
  • Bill McCarthy
    In some languages functions and variables can have `*` or `?` in valid names. iskeyword is set to include all valid name characters, including these. If I
    Message 1 of 2 , Mar 2, 2003
    • 0 Attachment
      In some languages functions and variables can have `*` or `?` in
      valid names. 'iskeyword' is set to include all valid name
      characters, including these.

      If I have a name `F*` and execute the normal command `*` on it,
      Vim searches for: \<F\*\> That's correct.

      If I have a name `bad?` and execute the normal command `*` on it,
      Vim searches for: \<bad\?\> That's wrong. Vim won't find any
      word `bad?`. Instead it will find the words `ba` and `bad` as
      requested by the constructed search command.

      Obviously, I can edit the resulting `/` command generated by the
      `*` command. Is there a better way?

      Bill
    • Bram Moolenaar
      ... This is a bug. For searching backwards ? must be escaped to avoid its special meaning. But for searching forwards ? is an ordinary character and ?
      Message 2 of 2 , Mar 3, 2003
      • 0 Attachment
        Bill McCarthy wrote:

        > In some languages functions and variables can have `*` or `?` in
        > valid names. 'iskeyword' is set to include all valid name
        > characters, including these.
        >
        > If I have a name `F*` and execute the normal command `*` on it,
        > Vim searches for: \<F\*\> That's correct.
        >
        > If I have a name `bad?` and execute the normal command `*` on it,
        > Vim searches for: \<bad\?\> That's wrong. Vim won't find any
        > word `bad?`. Instead it will find the words `ba` and `bad` as
        > requested by the constructed search command.
        >
        > Obviously, I can edit the resulting `/` command generated by the
        > `*` command. Is there a better way?

        This is a bug. For searching backwards "?" must be escaped to avoid its
        special meaning. But for searching forwards "?" is an ordinary
        character and "\?" has a special meaning (same as "\="). Please try
        this patch and let me know if this fixes your problem:

        *** normal.c~ Mon Mar 3 13:05:49 2003
        --- normal.c Mon Mar 3 20:55:23 2003
        ***************
        *** 4827,4833 ****
        /*
        * Now grab the chars in the identifier
        */
        ! if (cmdchar == '*' || cmdchar == '#')
        aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
        else if (cmdchar == 'K' && *p_kp != NUL)
        aux_ptr = (char_u *)" \t\\\"|!";
        --- 4827,4835 ----
        /*
        * Now grab the chars in the identifier
        */
        ! if (cmdchar == '*')
        ! aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
        ! else if (cmdchar == '#')
        aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
        else if (cmdchar == 'K' && *p_kp != NUL)
        aux_ptr = (char_u *)" \t\\\"|!";

        --
        Mynd you, m00se bites Kan be pretty nasti ...
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
      Your message has been successfully submitted and would be delivered to recipients shortly.