aboutsummaryrefslogtreecommitdiffstats
path: root/bundle/case_star
AgeCommit message (Collapse)Author
2019-12-13case-star: Get `c#` mapping working in the middle of a wordTeddy Wing
After trying a few different approaches, finally settled on a mapping implementation for `c#` that seems to work both at the start and in the middle of a word. Previously, as the TODO on line 1 indicates, if the cursor was on the start of the word, we'd move to the previous match using `c#`. However, if the cursor was in the middle of the word, `c#` would move to the start of the word, when it should instead move to the previous match. First tried to solve the movement problem using `search()`. Managed to find a formula that did what I wanted, but search highlighting isn't applied when searching within functions. This function (in particular the 'z' flag) allows us to move to the previous match even when starting in the middle of the word: call search('\C' . expand('<cword>'), 'bz')<CR> I then tried an <expr> mapping against a function that would call: call search('\<', 'bc') first to move to the start of the word (even when already on the start of the word), then return the `?...` command to run the search for the previous match. This, however, didn't work because the above mentioned `search()` call wasn't part of the <expr> mapping, and it's likely the search was undone, similar to what I encountered next. I then tried to run an `execute 'normal! ?...'` command to run the search, preceded still by the aforementioned `search()` call to move to the beginning of the word. This did not work because it turns out that searches in a function are undone when that function returns: :h function-search-undo This behaviour is also the likely reason why my `search()` + <expr> function didn't work. Finally, tried an <expr> mapping containing both the `search()` call to move to the beginning of the word and the `?...` command to search for the previous match (all returned in the <expr> string). Once I got the syntax right, this seems to do exactly what I want. Left the in-between code states for reference. I'll be cleaning those up later.
2019-12-09Add ideas for 'case_star' pluginTeddy Wing
Mappings for case sensitive versions # and *. Not completely figured out yet.