在shell脚本执行命令VIM [英] Executing VIM commands in a shell script

查看:760
本文介绍了在shell脚本执行命令VIM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个运行命令行程序(的Gromacs),将结果保存,修改输入文件,然后通过过程中再次循环bash脚本。我试图用VIM修改输入的文本文件,但我一直没能找到一种方法来执行内部VIM的命令,如:1234,W,X,DD,等。从sh文件后,VIM打开我的输入文件(VIM conf.gro)。

I am writing a bash script that runs a command line program (Gromacs), saves the results, modifies the input files, and then loops through the process again. I am trying to use VIM to modify the input text files, but I have not been able to find a way to execute internal VIM commands like :1234, w, x, dd, ect. from the .sh file after opening my input files in VIM ("vim conf.gro").

有从shell脚本执行命令VIM任何实际的方法?

Is there any practical way to execute VIM commands from the shell script?

推荐答案

我觉得 VIM -w / W和vim -S 是你在找什么。

I think vim -w/W and vim -s is what you are looking for.

在VIM操作/键序列,你可以用录制的vim -w test.keys input.file 另外,你可以写在测试。键太。例如保存此文件中的:

The "vim operations/key sequence" you could record with vim -w test.keys input.file also, you could write the test.keys too. e.g. save this in the file:

ggwxjddZZ

这会做什么:

move to 1st line, 
move to next word,
delete one char,
move to next line, 
del the line. 
save and quit.

test.keys 文件,你可以这样做:

vim -s test.keys myInput.file

你的myInput.file将由上述操作处理,并保存。你可以在你的shell脚本行。

your "myInput.file" would be processed by the above operations, and saved. you could have that line in your shell script.

vimgolf正在使用相同的方式,以节省用户溶液

vimgolf is using the same way to save users solution.

这篇关于在shell脚本执行命令VIM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆