Want to exactly matching current word with below function.
function! My_Exact_Search () let CurrentWord = expand("<cword>") exec "/\<".CurrentWord."\>" endfunction
But get error:
E486: Pattern not found: <word>.
How to fix it?
* command does this natively.
The problem with your function is you need to escape your
/ or use literal-string (I recommend).
let @/ = '/\<'.CurrentWord.'\>'
You also should be using
:normal to create the search.
execute "normal! /\\<".expand('<cword>')."\\>\<cr>"
For more help see:
:h * :h literal-string :h quote/