November 2018
Beginner
330 pages
7h 21m
English
Conditional statements are performed using if statements:
if g:animal_kind == 'cat' echo g:animal_name . ' is a cat'elseif g:animal_kind == 'dog' echo g:animal_name . ' is a dog'else echo g:animal_name . ' is something else'endif
You can also make this operation inline:
echo g:animal_name . (g:is_cat ? ' is a cat' : ' is something else')
Vim supports all of the logical operators you're used to from other languages:
For example, you can do this:
if !(g:is_cat || g:is_dog) echo g:animal_name . ' is something else'endif
In the previous example, you'll get to g:animal_name . ' is something else' only if neither g:is_cat or g:is_dog are true.
This can also be written with the && operator:
if ...