I think the 'iskeyword' option controls the characters that are seen as part of a word. For example, if it contains '-', then my-text is seen as one word and as two words if it doesn't contain the hyphen.
In your case, try ':verb set iskeyword?' to both see its value and where it was set. Salman On Tue, Mar 5, 2024, 01:48 'lijh8' via vim_use <[email protected]> wrote: > Hi community, > > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vim_use/tencent_3174790CB14343CFF9B4C1411891C65F9308%40qq.com > . > -- -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEeeLazHRz034eh5hUdBYiDxbt_888p8_%3DYkedSWybmPVQ%40mail.gmail.com.
