[Problem Description]
I hope it won’t jump out of Vim
I hope it is: in normal-mode, press a certain key, and then there will be a small shell window below for easy observation of the output (just like IDE does That)
Sometimes just to test some ideas, frequently switching between Vim and Shell is not the answer
[Environment & Reproduction]
Ubuntu14-Vim7.4 (not compatible with Vi)
update
Solved
Don’t reinvent the wheel. The one you make yourself is not only bad, but also because you are not familiar with the syntax of vim script, it will end up being a crappy wheel
Please Google search 'vim quickrun'
伊谢尔伦2017-05-16 16:39:03
Direct execution :!python a.py
可以啦!
另外非要映射快捷键的话,我使用了一个大神的vim配置,很完善,k-vim, 他里面就有一个运行按键设置::F10
就跟:!python a.py
The effect is the same,
阿神2017-05-16 16:39:03
vim’s make will display the execution results below.
I am not particularly satisfied with the plug-in for executing shell in vim. So I later used tmux and vim, but some problems may occur, and it always feels bad in a system with a gui.
So now I use vim + tilda. There are many gadgets similar to tilda. You can search for them. I even forgot what they are called.
我想大声告诉你2017-05-16 16:39:03
You will definitely know how to split windows
! ! Execute the command line and write the results to the current buffer
Macros and key bindings
The combination of these is what you want
世界只因有你2017-05-16 16:39:03
@shomy’s method could be slightly improved:
:!python %
% refers to the current file, you need to save it before executing.
天蓬老师2017-05-16 16:39:03
Recommended to use https://github.com/klen/python-mode
Run python scripts directly, also supports virtualenv
Run python code (<leader>r)
漂亮男人2017-05-16 16:39:03
This is mine:
function Result_of_run(run_sign)
"!ls这样运行, 显示的结果会切换到shell界面
echo system(a:run_sign . shellescape(expand('%')))
endfunction
autocmd BufNewFile,BufRead *.py nnoremap <buffer> <F2> :up<CR>:call Result_of_run("python ")<CR>
漂亮男人2017-05-16 16:39:03
You can use neovim, built-in terminal, you can refer to my configuration (compatible with vim)
https://github.com/wsdjeg/DotFiles