I've got a config file that I want to manipulate from this..
Input file
["12000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12000",["127.0.0.1:12000"]]
..to the following:
Output file
[
"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"
]
]
So I've created a script file that runs a nvim -e -c 'command' -c ..etc.
and one particular -c line contains the following:
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"' \
...
And I want to turn that into
run.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"' \
...
But I can't do that as the characters will be read literally.
I'm also not very familiar with this style of editing as the only info I could find on using (n)vim -e -c 'command' is on a single page: https://blog.robertelder.org/use-vim-inside-a-unix-pipe-like-sed-or-awk/ but it's probably the best way to do this.
Does anyone here have experience with this and can anyone tell me how one can use (n)vim to use variables in vim executable commands in normal mode?