I use this to highlight occurrences of the word when cursor is inside
the word, and cancel the highlight when cursor is outside.
```
autocmd CursorMoved,CursorMovedI * execute 'match Visual' (getline('.')[col('.')-1] =~# '\w' ? '/\<' . escape(expand('<cword>'), '/\.*$^~[]') . '\>/' : '//')
```
When i `:help autocmd` and read lines like these:
` autocmd_add({replace: `
` autocmd_add(#{replace: `
(backticks are not part of them)
if I place cursor on ` autocmd_add ` or ` replace `,
this whole string ` autocmd_add({replace: ` is highlighted as a whole
wrongly, and this is wrong too ` autocmd_add(#{replace: `.
But when I open the file directly with vim:
` $ vi /usr/share/vim/vim90/doc/autocmd.txt `
` autocmd_add ` and ` replace ` are not highlighted together as a whole.
it seems that the pattern does not count ` ( `, ` # `, ` { ` as boundary
of words in ` :help ` buffer. how can I fix it?
Thanks!</cword>
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/tencent_3174790CB14343CFF9B4C1411891C65F9308%40qq.com.
I update this to highlight cursor word, it now works in `:help` system and it also works to the built-in star `*` .
Thanks
```
let save_isk=&iskeyword | set iskeyword=@,48-57,_,192-255 | autocmd CursorMoved,CursorMovedI * execute 'match Visual' (getline('.')[col('.')-1] =~# '\w' ? '/\<' . escape(expand('<cword>'), '/\.*$^~[]') . '\>/' : '//') | let &iskeyword=save_isk
```</cword>
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/tencent_ACEA18DFC679933C79DCB1CF4376F93EC108%40qq.com.