Is is possible to search for a regexp in only the current line.Here is an example line:This is some text that I have written. Can you find this word?                                                    ^This line contains many t's. I would like to search forward for this so the cursor ends up at the caret (the ^ character).The problem with using / is that if the pattern does not match in the line the cursor will jump to another part of the buffer. I do not want that behavior. I want the search to stop if there is no match in the line.I can of course search forward using ft and press ; repeatedly but if I were to record macro that would make the macro inconsistent when executed at different locations.The most obvious solution would be :./this but that did not work for me (it finds matches at other lines in the buffer). So it appears to me that Vim is lacking this feature.Do you know of a way to do what I am describing?
How to search forward for pattern in the current line? Like `/` and `?` but stop at end of line
regular expression;search
You can do::call search('find', '', line('.'))... where 'find'is the pattern. The cursor will be moved to the start of the match.Sample interactive mapping (not perfect)::nnoremap <leader>/ :call search(input(Pattern: ), '', line('.'))<cr>Also: with several plugins that enhance Vim grammar (operator-search, textobj-line (*)), you can do::map g/ <Plug>(operator-search)and then:g/il... i.e. go search for pattern (g/) in this line (il). But also:g/is(search in this sentence). Or, visually select a range, move cursor to the end, hit g/ to search inside the visual selection. Press n for next match, etc.(*) Note that these plugins depend on their generic counterparts, Kana's textobj-user and operator-user.