jundymek
jundymek

Reputation: 1043

Running python code directly in Vim

I want to run a python program directly in vim. I type

:w !python 

I get error

'no module named...' or 'no such file or directory: 'file.json''.

It occurs only when I load file after opening vim. When I start vim typing gvim filename.py, it works fine (:w !python works). What is wrong here?

Upvotes: -1

Views: 2518

Answers (1)

jundymek
jundymek

Reputation: 1043

I solved it by adding this to my _vimrc config file:

noremap <F5> :w !python %<CR>
inoremap <F5> <ESC>:w !python %<CR>

Upvotes: 0

Related Questions