document updated 13 years ago, on Sep 8, 2011
Very gentle introduction to basic syntax
:echo 'foo bar'
Displays that string.
:echo &modeline
This is how to display a built-in setting's value.
:echo tolower("FOOBAR") | echo "The ASCII value of 'o' is " char2nr("o")
There are
many functions available.
:let cmd = 'echo' | execute cmd 'tolower("FOOBAR")'
:execute can make variable-interpolation work, akin to eval().
:debug let cmd = 'echo' | execute cmd 'tolower("FOOBAR")'
Prepending '
debug' and then typing 'step' repeatedly can be illuminating.
:let varA = "foo" | let varB = "bar"
:execute 'echo "' varA varB '"'
|" displays " foo bar"
:execute 'echo "'
. varA
. varB
. '"' |" displays "foobar"
Both 'execute' and 'echo'
always add a space between their arguments. However, you can use the string-concatenation operator ('.') to avoid this space-adding behavior.
More complicated syntax