Every Python statement in Vim should be prefixed with the :python
command, to instruct Vim that the next command is not Vimscript but Python.
To avoid typing this command on each line, when executing multi-line Python code, it is possible to instruct Vim to interpret the code between two marker expressions as Python.
To achieve this, use:
:python << {marker_name}
a = "Hello World"
print(a)
{marker_name}
where {marker_name}
is the word you want to use to designate the end of the python block.
E.g.:
:python << endpython
surname = "Doe"
forename = "Jane"
print("Hello, %s %s" % (forename, surname))
endpython
would print:
Hello, Jane Doe