Viml conditionals: Difference between revisions
From wikinotes
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ WARNING | | {{ WARNING | | ||
in vim, <code>0</code> is FALSE, and <code>1</code> is TRUE. | in vim, <code>0</code> is FALSE, and <code>1</code> is TRUE. | ||
}} | |||
{{ WARNING | | |||
comparing mis-matching types will return FALSE | |||
}} | }} | ||
Line 7: | Line 10: | ||
<source lang="vim"> | <source lang="vim"> | ||
" If Statement | " If Statement | ||
if | if var == 1 | ||
echo var | echo var | ||
elseif | elseif var == 2 || var == 3 | ||
echo var | echo var | ||
else | else | ||
Line 18: | Line 21: | ||
<source lang="vim"> | <source lang="vim"> | ||
" If Not Statement | " If Not Statement | ||
if !( var == 1 ) | if !(var == 1) | ||
echom "var doesn't equal 1" | echom "var doesn't equal 1" | ||
endif | endif | ||
Line 25: | Line 28: | ||
<source lang="vim"> | <source lang="vim"> | ||
" If And Statement | " If And Statement | ||
if | if var == 1 && var != 0 | ||
echom "condition satisfied | echom "condition satisfied | ||
endif | endif | ||
</source> | </source> | ||
</blockquote><!-- If Statements --> | </blockquote><!-- If Statements --> |
Latest revision as of 03:03, 11 February 2023
WARNING:
in vim, 0
is FALSE, and 1
is TRUE.
WARNING:
comparing mis-matching types will return FALSE
If Statements
" If Statement if var == 1 echo var elseif var == 2 || var == 3 echo var else echo var endif" If Not Statement if !(var == 1) echom "var doesn't equal 1" endif" If And Statement if var == 1 && var != 0 echom "condition satisfied endif