相关疑难解决方法(0)

从python脚本中调用EDITOR(vim)

我想在python脚本中调用一个编辑器来征求用户的意见,就像crontab e或者git commit一样.

这是我到目前为止运行的片段.(将来,我可能会使用$ EDITOR而不是vim,以便人们可以根据自己的喜好进行自定义.)

tmp_file = '/tmp/up.'+''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(6))
edit_call = [ "vim",tmp_file]
edit = subprocess.Popen(edit_call,stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True )   
Run Code Online (Sandbox Code Playgroud)

我的问题是,通过使用Popen,它似乎让我的i/o与python脚本进入vim的运行副本,我找不到一种方法来将i/o传递给vim.我收到以下错误.

Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
Run Code Online (Sandbox Code Playgroud)

什么是从python调用CLI程序,手动控制到它的最佳方法,然后在完成后将其传回去?

python vim editor command-line-interface

42
推荐指数
3
解决办法
1万
查看次数

如何将缓冲区内容写入stdout?

有没有机会将当前vim缓冲区的内容写入stdout?

我想使用vim编辑通过stdin传递的内容 - 无需临时文件来检索修改后的内容(在Linux/Unix上).

是否有可能插件/脚本 - 退出或保存时将缓冲区内容放入stdout?

vi vim shell stdout

31
推荐指数
4
解决办法
1万
查看次数

标签 统计

vim ×2

command-line-interface ×1

editor ×1

python ×1

shell ×1

stdout ×1

vi ×1