从终端以特定的“:”模式打开 Vim

To open Vim in specific ":" mode from terminal

我在检查数据时使用 Vim。 我想以特定的“:”模式启动 Vim,例如在终端中处理二进制数据:

xxd -ps r328_0000.raw > /tmp/1 && vim /tmp/1 :%s/ffff//gn
                                            |
                                            ?

如何在终端中以“:”模式启动 Vim?

您可以像这样使用 -c 选项(或只是 +)来执行此操作:

vim -c "%s/ffff//gn"
vim +"%s/ffff//gn"

来自联机帮助页:

+{command}

-c {command}
           {command}  will  be  executed after the first file has been
           read.  {command} is interpreted as an Ex command.   If  the
           {command}  contains  spaces  it  must be enclosed in double
           quotes (this depends on the shell that is used).   Example:
           Vim "+set si" main.c
           Note: You can use up to 10 "+" or "-c" commands.