XVimProject / XVim

Xcode plugin for Vim keybindings
MIT License
5.16k stars 595 forks source link

`*` should search to the next match of the word under the cursor #55

Closed kabuko closed 12 years ago

kabuko commented 12 years ago

Note sure if this requires text objects (#27), but * should search to the next match of the word under the cursor

kabuko commented 12 years ago

Current implementation is pretty close, but has some subtle differences with Vim. The differences are to do with the way it matches whole words. For example, if you put your cursor on init and press *, in Vim it won't match initWithFrame but in XVim's current implementation it will. I believe the current implementation could actually be correctly mapped to g*. Also, I know I didn't mention it in the original issue description, but # (and g#) should be trivial after the work already done for *.

kabuko commented 12 years ago

Some relevant docs from Vim:

*           Search forward for the [count]'th occurrence of the
            word nearest to the cursor.  The word used for the
            search is the first of:
                1. the keyword under the cursor |'iskeyword'|
                2. the first keyword after the cursor, in the
                   current line
                3. the non-blank word under the cursor
                4. the first non-blank word after the cursor,
                   in the current line
            Only whole keywords are searched for, like with the
            command "/\<keyword\>".  |exclusive|  {not in Vi}
            'ignorecase' is used, 'smartcase' is not.

                            *#*
#           Same as "*", but search backward.  The pound sign
            (character 163) also works.  If the "#" key works as
            backspace, try using "stty erase <BS>" before starting
            Vim (<BS> is CTRL-H or a real backspace).  {not in Vi}

                            *gstar*
g*          Like "*", but don't put "\<" and "\>" around the word.
            This makes the search also find matches that are not a
            whole word.  {not in Vi}

                            *g#*
g#          Like "#", but don't put "\<" and "\>" around the word.
            This makes the search also find matches that are not a
            whole word.  {not in Vi}
dojoteef commented 12 years ago

Please let me know if I've covered the bases correctly with issue #88. If so, we can close this issue out.

kabuko commented 12 years ago

This looks good to me. Thanks!