开发者

Opening Vim and using some command in normal mode from the Terminal?

I want to be able to open Vim and automatically make some commands in normal mode (in this case, open two buffers put a mark in one line on one line, fold another line, and go to the bottom of the file). The closest thing I found would be using the -c or + command line switch, howeve开发者_运维百科r these execute commands in Ex mode.

For example, I would like to be able to write something like this:

vim -some ":e a<CR>:e b<CR>23Gma55GzfG"

To do all the commands.


Why don't you like normal command? It is not able to execute ex mode commands, but is able to use all other modes:

vim -c 'e a' -c 'e b' -c 'normal! 23Gma55GzfG'

Bang at the end of command is required if you want to be sure that it will not use any mappings.


Define this command in your _vimrc file (you can name it something other than Onstart, but it must start with a capital letter)

:command -nargs=1 Onstart <args>

From the command line you should be able to call this:

gvim c:\file.txt -c "Onstart e a<CR>:e b<CR>23Gma55GzfG"

correction

Nope, I was mistaken. You'd just have to pipe the commands:

vim -c "e a | e b | normal!23Gma55GzfG"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜