I usually use * and # (as suggested by Brian Agnew), but if you want to use a method that includes input
?word<CR>
you can do something like this:
function! SearchWord(word) let @/ = '\<' . a:word . '\>' normal n endfunction command! -nargs=1 SearchWord call SearchWord(<f-args>) nmap ? :SearchWord
Notice that the last line has a space after SearchWord .
Explanation:
Does the mapping do ? open a command prompt and type SearchWord (including space). The command makes SearchWord myword equivalent to call SearchWord('myword') (i.e., puts quotation marks around the argument to turn it into a string). The function sets the search register @/ to your word surrounded by \< and \> , and then executes normal mode n to find the next instance of the contents of the search register.
Of course, you lose the benefits of incremental search if you do this, but hopefully it is still useful.
source share