简体   繁体   English

在VIM中将内置命令与外部命令链接

[英]Chain builtin commands with external commands in VIM

Is there a way to chain external commmands into built in commands on the vim command line? 有没有办法将外部命令链接到vim命令行上的内置命令中? I wanted to do something like this: 我想做这样的事情:

vsp !git diff --name-only

I have tried 我努力了

vsp system('git', 'diff', '--name-only')

and

vsp `!git diff --name-only\`

(y'know, just in case. Other bash things seem to just work in vim) to no avail. (您知道,以防万一。其他bash事情似乎只在vim中起作用)无济于事。 Does anybody know of a way to do this. 有人知道这样做的方法吗? I would of course only have modified one file. 我当然只会修改一个文件。 Thanks in advance! 提前致谢!

I also tried :execute "vsplit " . !git diff --name-only 我也尝试:execute "vsplit " . !git diff --name-only :execute "vsplit " . !git diff --name-only , vsplit exec "!git diff --name-only" , and :execute "vsplit " . exec "!git diff --name-only" :execute "vsplit " . !git diff --name-onlyvsplit exec "!git diff --name-only":execute "vsplit " . exec "!git diff --name-only" :execute "vsplit " . exec "!git diff --name-only" . :execute "vsplit " . exec "!git diff --name-only" No luck 没运气

-- EDIT -- -编辑-

So I was completely off… 所以我完全离开了...

You only need to put git diff --name-only between backticks: 您只需要在反引号之间放置git diff --name-only

:vsplit `git diff --name-only`

Be aware that :vsplit , like :edit and friends only takes one argument so the command above will fail if you have two or more files. 请注意, :vsplit ,例如:edit和friends仅接受一个参数,因此,如果您有两个或多个文件,上述命令将失败。

You should probably use :next instead: 您可能应该使用:next代替:

:vnew|next `git diff --name-only`

-- ENDEDIT -- -ENDEDIT-

You could do something like this: 您可以执行以下操作:

:vnew|0r!git diff --name-only
  • create a new buffer in a vertical window, 在垂直窗口中创建一个新的缓冲区,
  • insert the output of git diff --name-only at the top of that empty buffer. git diff --name-only的输出插入该空缓冲区的顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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