2013-10-22 201 views

回答

1

这可能不是你超越它,只是你在编程语言之前没有遇到过!。这很简单,但这是一个快速解释。

如果您想根据某个条件做某件事,那么您使用if语句,对吧?例如,

if has('relativenumber') 
    echo "Your Vim has the relative number feature!" 
endif 

如果你想要做的事,如果这一条件是真的,你的条件之前把!。 (这被称为“否定”逻辑条件)

if !has('relativenumber') 
    echo "Your Vim does NOT have the relative number feature." 
endif 

你也可以在其他情况下使用它。拿这个,例如:

if x > 3 
    echo "x is greater than three" 
endif 

你必须包括圆括号否定它。 (操作顺序!)

if !(x > 3) 
    echo "x is less than or equal to three" 
endif 

这相当于

if x <= 3 
    echo "x is less than or equal to three" 
endif 
+0

好吧,现在它是有道理的。也许我正在自己领先一点。我无法磨合一种我不得不否定价值的情况。请记住,我刚刚在2个月前拿起了Vim。 –

+0

这不像一个编程事物那么简单。你可能会在某个时候需要,现在你会知道该怎么做。我不会为此担心。 – pandubear

+0

有点无关:我正在使用Vim7.4,并且使用has('relativenumber')并不适合我。什么*做*工作:如果存在('&relativenumber')。 –

相关问题