
There are a few different ways to do this, either you can embed a Python block in a Vimscript function or use a map or a macro to call a Python function. To do more complicated Python code, you’ll want to start embedding your code into functions.

You can use the Python command whenever you need a little Python right away, but as you might have noticed from the previous example, its standard output goes to the status line, not to the document. If the status bar displays hi, then you’re in business. You can check if your Vim program has Python support by typing the following command: :python print "hi" The following commands only work if your version of Vim has been compiled with the -python flag set, pre-built versions of Vim later than version 7.0 have this flag set by default, older versions may not.

If you’ve ever tried to add your own functionality to the editor but been turned off by its arcane Vimscript language, then you’ll be pleased to know that Vim now supports internal Python scripting. If you’re a user of the text editor Vim, chances are you are already impressed with the number and power of its inbuilt features. If you've ever tried to add your own functionality to the editor but been turned off by its arcane Vimscript language, then you'll be pleased to know that Vim now supports internal Python scripting. If you're a user of the text editor Vim, chances are you are already impressed with the number and power of its inbuilt features.
