What does pipe character do in vim command mode? (for example, :vimgrep /pattern/ file | another_cmd)

穿精又带淫゛_ 提交于 2019-12-24 05:05:08

问题


What does pipe character do in vim command mode?

For example, :vimgrep /pattern/ file | copen

Does it act like a pipe in Linux Command Line? Contents of vimgrep gets piped to copen?

Or does it separate commands like ; in Command Line?


回答1:


| is used to execute more than one command at a time.

In your example:

:vimgrep /pattern/ file | copen

This finds for the pattern in the specified file and then opens a window to show current list of occurrence of pattern.

The second command (and subsequent commands) are only executed if the prior command succeeds.




回答2:


To OP's question: the latter.

This is actually a vi feature, not vim-specific, used to separate multiple commands. It was answered before here:

  • What does <Bar> mean?
  • Learning the Vi and Vim Editors, "special meaning as a separator of multiple ex commands".


来源:https://stackoverflow.com/questions/32943945/what-does-pipe-character-do-in-vim-command-mode-for-example-vimgrep-pattern

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!