Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VIM-删除组的匹配项_Vim_Neovim - Fatal编程技术网

VIM-删除组的匹配项

VIM-删除组的匹配项,vim,neovim,Vim,Neovim,我有一个小功能,可以在每个单词下面画下划线,就像光标下的单词一样: function! HighlightWordUnderCursor() hi MatchWord NONE let disabled_ft = ["qf", "fugitive", "nerdtree", "gundo", "diff", "fzf", "floaterm"]

我有一个小功能,可以在每个单词下面画下划线,就像光标下的单词一样:

function! HighlightWordUnderCursor()
  hi MatchWord NONE
  let disabled_ft = ["qf", "fugitive", "nerdtree", "gundo", "diff", "fzf", "floaterm"]
  if &diff || &buftype == "terminal" || index(disabled_ft, &filetype) >= 0
    return
  endif
  if getline(".")[col(".")-1] !~# '[[:punct:][:blank:]]'
    hi MatchWord cterm=undercurl gui=undercurl guibg=#3b404a
    exec 'match' 'MatchWord' '/\V\<'.expand('<cword>').'\>/'
  else
    match none
  endif
endfunction

augroup MatchWord
  autocmd!
  autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor()
augroup END

函数!HighlightWordUndersor()
嗨,火柴字一个也没有
let disabled_ft=[“qf”、“逃犯”、“nerdtree”、“gundo”、“diff”、“fzf”、“FlotterRM”]
if&diff | |&buftype==“终端”| |索引(禁用的| ft,&filetype)>=0
返回
恩迪夫
如果getline(“.”[col(“.”-1]!~#”[[:punct:][:blank:][]
hi MatchWord cterm=underl gui=underl guibg=#3b404a
exec“匹配”匹配词“”/\V\/'
其他的
不匹配
恩迪夫
端功能
组匹配词
自动驾驶!
自动驾驶!CursorHold,CursorHoldI*调用HighlightWordUndersersor()
螺旋端
但是,在diff模式下,它仍然匹配,但在黄色更改线上为黑色。我怎样才能修好它?谢谢


值得注意的是:在非差异行上,高亮显示并没有按预期进行。

为什么您有这样的功能?为什么不直接使用
*
?@DoktorOSwaldo我希望我能否决你的评论。很抱歉你这么想。然而,我不是想欺负你,我是认真地问。我相当肯定你知道那种可能性。这就是为什么我想知道这背后的原因是什么…@DoktorOSwaldo看看autocmd。我正在复制一个vscode行为,即在光标下标记符号,而不是搜索它,我不想污染我的
@/
寄存器,在代码中看到类似的关键字非常有用。谢谢。您对
&diff
的检查实际上看起来是正确的。您是否尝试添加断点以查看它是否确实跳过
if
块<代码>断开添加函数HighlightWordUnderCorsor