I am using Manjaro/Arch Linux and I use vim from sudo pacman -S vim
instead of build it from source
I want to run my .py
files in vim by F5 but when I added these to ~/.vimrc
:
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java %<"
elseif &filetype == 'sh'
:!time bash %
elseif &filetype == 'python'
exec "!time python %"
elseif &filetype == 'html'
exec "!firefox % &"
elseif &filetype == 'go'
" exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'mkd'
exec "!~/.vim/markdown.pl % > %.html &"
exec "!firefox %.html &"
endif
endfunc
it will show (originally in Chinese)
function CompileRunGcc --> error
In line 1:
E382: cannot write in,has been set as 'buftype'
when running .py files
I am using anaconda as my default python environment, and I installed them at ~/.anaconda
write
,!g++ % -o %<
, etc. And you may be interested in:help :compiler
and:help :make
.