如何使用变量在正常模式下使用`nvim -e file -c`命令?
我有一个要从此操作的配置文件..
输入文件
["12000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12000",["127.0.0.1:12000"]]
..到以下内容:
输出文件,
[
"12000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12000",
[
"127.0.0.1:12000",
"127.0.0.1:12001",
"127.0.0.1:12002",
"127.0.0.1:12003",
"127.0.0.1:12004",
"127.0.0.1:12005",
"127.0.0.1:12006",
"127.0.0.1:12007",
"127.0.0.1:12008",
"127.0.0.1:12009",
"127.0.0.1:12010",
"127.0.0.1:12011",
"127.0.0.1:12012",
"127.0.0.1:12013",
"127.0.0.1:12014",
"127.0.0.1:12015"
]
]
因此我创建了一个运行的脚本文件 nvim -e -c'命令'-c ..etc。
一个特定的-c行包含以下内容:
run.sh
...
HOST_IP=127.0.0.1
HOST_PORT=12000
NUM_NODES=15
...
/usr/bin/nvim -e output.txt \
...
-c 'exe "norm /\"127.0.0.1:12000\"\n$a,\<ESC>yy15p14\n$x"' \
...
,我想将其转换为
run.sh.sh ,
...
HOST_IP=127.0.0.1
HOST_PORT=12000
NUM_NODES=15
...
/usr/bin/nvim -e output.txt \
...
-c 'exe "norm /\"${HOST_IP}:${HOST_PORT}\"\n$a,\<ESC>yy${NUM_NODES}p$(($NUM_NODES-1))\n$x"' \
...
但我不能这样做,因为字符将被读取字面上地。
我也不熟悉这种编辑风格 作为我唯一可以在使用(n)vim -e -c'命令'的信息,它在一个页面上: 但这可能是这样做的最好方法。
这里有人有经验吗 谁能告诉我如何使用(n)vim在 VIM可执行命令在正常模式下?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现一个人可以使用-es选项
为了从多行脚本编写正常模式命令。
不确定,但是我认为
&lt;&lt; -
中的额外负数使脚本读取shell脚本变量。
I discovered that one can use the -es option
in order to write normal mode commands from an multiline script.
Not sure, but I think extra minus in
<<-
makes the script read shell script variables.