E.g. given 1st line "what to edit" and 2nd line "what vim commands to execute"
-E
Ex mode: vim will treat STDIN as if it's just list of commands- here
^E
means key press, so here 2 strategies to deal with it- replace
^E
with new_line + ":norm " - replace
^E
with hex code of ESC which is\x1b
- replace
head -1 > 1.tmp
vim -E 1.tmp <<EOF
:norm `sed 's/\^E/\n:norm /g'`
:wq
EOF
cat 1.tmp
or print to the STDOUT instead of file
head -1>1
vim -e 1 <<<"norm `sed 's~\^E~\x1b~g'`
%p|q"
- p = print