Learning the syntax
Let’s take a lightning-fast deep dive into Vimscript’s syntax.
Prior knowledge required!
This section assumes you’re comfortable with at least one programming language, conditional statements, and loops in particular. If that’s not the case, you will most certainly be better off finding a more extensive tutorial. Vimscript deserves its own book, and Steve Losh wrote just that: Learn Vimscript the Hard Way is easily the best Vimscript tutorial available (and it’s free on the web!).
Setting variables
You’ve already discovered some basics of Vimscript syntax. To set internal Vim options, you use the set
keyword:
set background=dark
Reminder
Don’t forget, you can run :source %
to execute the current file.
To define a variable, you can use let
(for variables):
let dish = 'spam omelet'
To assign a value to a non-internal variable, you’ll again use the let
keyword:
let dish...