这个 vim 脚本可以正常工作了
#!/usr/bin/vim
%!sed 's/ .*//'
%!sort -fu
norm dd
% norm $D
唯一的问题是最后的这条消息(我必须按键盘中的 ENTER)
"20 lines filtered
20 lines filtered
Press ENTER or type command to continue
"
如何在脚本中模拟ENTER?所以我可以避免手动按下我把它放在脚本的末尾但不起作用
norm <^M>
检查问题的是 sed (产生输出),而不是 vim。如何让 sed 更安静?使用“sed -n”会产生空输出。
尝试使用带有这些行的文本