How can you use Python in Vim?

In any of your vim windows, type something like this:

for x in range(1,10):
    print '-> %d' % x

Visually select both of those lines (V to start visual mode), and type the following:

:!python

Because you pressed ‘:’ in visual mode, that will end up looking like:

:'<,'>!python

Hit enter and the selection is replaced by the output of the print statements. You could easily turn it into a mapping:

:vnoremap <f5> :!python<CR>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)