search

Home  >  Q&A  >  body text

When using Vim to edit scripts such as Python, how can I embed a small shell below to facilitate observing the output results?

[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'

phpcn_u1582phpcn_u15822834 days ago712

reply all(10)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 16:39:03

    Can be used:

    • neovim’s terminal

    • tmux + vim

    • vim + Conque-Shell

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 16:39:03

    Direct execution :!python a.py 可以啦!
    另外非要映射快捷键的话,我使用了一个大神的vim配置,很完善,k-vim, 他里面就有一个运行按键设置::F10 就跟:!python a.pyThe effect is the same,

    reply
    0
  • 阿神

    阿神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.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你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

    reply
    0
  • 世界只因有你

    世界只因有你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.

    reply
    0
  • 天蓬老师

    天蓬老师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)

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 16:39:03

    Use neovim, which has a terminal window.

    reply
    0
  • 漂亮男人

    漂亮男人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>

    reply
    0
  • 漂亮男人

    漂亮男人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

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 16:39:03

    nnoremap <leader>r :!%:p<CR>

    reply
    0
  • Cancelreply