[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'
Can be used:
neovim’s terminal
tmux + vim
vim + Conque-Shell
Direct execution
:!python a.py
可以啦!另外非要映射快捷键的话,我使用了一个大神的vim配置,很完善,k-vim, 他里面就有一个运行按键设置::
F10
就跟:!python a.py
The effect is the same,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.
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
@shomy’s method could be slightly improved:
:!python %
% refers to the current file, you need to save it before executing.
Recommended to use https://github.com/klen/python-mode
Run python scripts directly, also supports virtualenv
Run python code (<leader>r)
Use neovim, which has a terminal window.
This is mine:
You can use neovim, built-in terminal, you can refer to my configuration (compatible with vim)
https://github.com/wsdjeg/DotFiles
nnoremap <leader>r :!%:p<CR>