简体   繁体   中英

To open Vim in specific “:” mode from terminal

I use Vim in inspecting data. I would like to start Vim in specific ":" mode, for instance processing binary data in Terminal:

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

How can you start Vim in the ":"-mode in terminal?

You can do this with the -c option (or just +) like this:

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

From the manpage:

+{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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM