【问题标题】:What does -= and += mean in the function?-= 和 += 在函数中是什么意思?
【发布时间】:2017-07-11 11:32:24
【问题描述】:
au FileType php call PHPFuncList()    
function PHPFuncList()    
    set dictionary-=/etc/vim/php_funclist.txt dictionary+=/etc/vim/php_funclist.txt    
    set complete-=k complete+=k    
endfunction

对于上面的PHPFunctionList,函数体中的两行让我很困惑。

set dictionary-=/etc/vim/php_funclist.txt dictionary+=/etc/vim/php_funclist.txt    
set complete-=k complete+=k 

对于这两行,首先 -= 删除它,然后 += 重新添加它。

为什么不能只写+=这两行呢?

set dictionary+=/etc/vim/php_funclist.txt    
set complete+=k 

它们之间存在差异吗?
:h set-=指出,当该选项是标志列表时,{value}必须完全在选项中显示。逐一删除标志以避免出现问题。
避免出现什么问题?

【问题讨论】:

  • 我猜开发者不明白+= 的工作原理,并使用-= 来确保不会添加两次。

标签: vim completion


【解决方案1】:

在 vim 文档中:

:h :set+=

:h :set-=

已经清楚地解释了用法。基本上+= 会将一个元素附加到选项中,-= 将从选项中减去该值。

【讨论】:

  • 我认为直接用+=添加效果是一样的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-12
  • 2017-06-11
  • 2018-03-05
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多