2024-04-28 21:09:27 发布
网友
我在uvimrc里加了一行。在
map <F4> :w<cr>:!python %<cr>
如果文件包含名称,则可以运行;如果该文件是新编辑的且不包含名称,则当我按F4时,它无法运行。 我想让我的配置更智能,而且不想保存它,给它一个名称,然后按F4,如何修改map <F4> :w<cr>:!python %<cr>使这个没有名字的python文件运行?在
使用:w !{cmd}怎么样?(这不需要在运行命令之前保存)。在
:w !{cmd}
:map <F4> :w !python<cr>
根据vimhelp :w_c:
help :w_c
:[range]w[rite] [++opt] !{cmd} Execute {cmd} with [range] lines as standard input (note the space in front of the '!'). {cmd} is executed like with ":!{cmd}", any '!' is replaced with the previous command |:!|.
:[range]w[rite] [++opt] !{cmd}
Execute {cmd} with [range] lines as standard input (note the space in front of the '!'). {cmd} is executed like with ":!{cmd}", any '!' is replaced with the previous command |:!|.
注意如果Python程序本身使用filename,这将无法按预期工作。(例如,__file__将生成'<stdin>')
__file__
'<stdin>'
使用
:w !{cmd}
怎么样?(这不需要在运行命令之前保存)。在根据vim
help :w_c
:注意如果Python程序本身使用filename,这将无法按预期工作。(例如,
__file__
将生成'<stdin>'
)相关问题 更多 >
编程相关推荐