Original title link: Reposted from Craftsmanship Community CodingStyle
I finally installed Vim Shell on my own Vim, but now I still encounter some configuration problems. I came here specifically to ask for advice, thank you in advance!
Please refer to the document: vimshell.txt on Github
As mentioned in the reference document, <C-c> is a shortcut key to terminate a running script. This shortcut key will trigger a function, which will send an interrupt request. However, it seems that this shortcut key is only effective in two situations:
When Vim Shell is waiting for user input, the effect of pressing <C-c> is equivalent to pressing Enter, and Vim Shell will create a new line;
When using the time built-in command. For example, enter time python test.py
in Vim Shell, and press <C-c> while waiting, the script will end immediately;
However, it will have no effect in other situations. For example, when entering exe python test.py
in Vim Shell, or when entering VimShellInteractive python test.py
in Vim Command, this shortcut key is useless. why is that?
The problem is simple, but I can't solve it. Now, I can enter VimShellInteractive python test.py
in Vim Command to execute the test.py script I am editing. But if I want to implement the shortcut key for running a python script with one click, how should I configure vimrc? The main question is, how can I pass the full path and filename of the file I'm editing to VimShell.
Thanks!
Weiming 20/5/2016
高洛峰2017-05-16 16:38:51
Second question:
The answer is in line 47 of the window below
Supplement: You can try this https://github.com/thinca/vim-quickrun
It can automatically identify your file type and call the corresponding interpreter,
The premise is not to write #!shebang under Windows
5/22 /2016
QuickRun supplementary picture
Well, I just tried it, js can also run quickly, Java can automatically javac Class.java and then java Class
You don’t need to write the file name yourself, other file types can also be defined by yourself
I changed a little bit of settings myself
let g:quickrun_config = {}
let g:quickrun_config._ = {
\ 'outputter/buffer/split': ''
\ }
autocmd FileType quickrun resize 10
map <Leader>q :QuickRun<CR>
5/24/2016
shebang refers to the first line of the script file
#!/bin/bash
Content like this, such as my first screenshot #!/usr/bin/env python
, under Linux the shell will call this program and take the script file as the first parameter. #!/usr/bin/env python
,在Linux 下 shell 会调用这个程序,并将脚本文件作为第一个参数。
QuickRun 完美兼容 shebang
第一张截图那样的代码,QuickRun 会尝试运行 /usr/bin/env python /path/to/file.py
QuickRun is perfectly compatible with the shebang
For code like the first screenshot, QuickRun will try to run /usr/bin/env python /path/to/file.py
Of course, there is no concept of shebang in Windows itself#!shebang
PS: 你可以在Windows 下看看 PythonScripts
目录下的 *.py
, 这些文件都有加入 #!shebang
In short, there is no need to add #!shebang
when writing scripts under Windows
PythonScripts
directory under Windows *.py
, these files have been added #!shebang
5/24/2016🎜