简体   繁体   English

在Vim命令模式下选择引用以传递到终端

[英]Reference selection in Vim command mode to pass on to terminal

Is there something like % (that represents the whole buffer in Vim command line ) for the current selection, so that I can do something like: :# sort (Imagine # represents the selection). 对于当前选择是否有类似% (代表Vim command line的整个缓冲区),所以我可以做类似的事情:# sort (想象#代表选择)。

EDIT: 编辑:

Sorry, I missed to mention that I am requesting for a way to operate on block selections not on ordinary selections that can be operated using ranges '<,'> . 抱歉,我没有提到我要求一种对块选择进行操作的方法,而不是对可以使用范围'<,'>进行操作的普通选择进行操作的方法。

Yes. 是。 Example: 例:

:'<,'>!sort
  • The range :'<,'> represents the visually selected lines. 范围:'<,'>代表视觉上选择的行。
  • :* is shorthand for :'<,'> :*:'<,'>简写
  • If you hit : while in visual mode it will start the command with '<,'> 如果你打:而在视觉模式,将开始与命令'<,'>

For more help see: 有关更多帮助,请参见:

:h '<
:h v_:
:h range

You are probably looking for the marks '< and '> : 您可能正在寻找'<'>标记:

:'<,'>sort

If you just select a few lines and hit : to enter the command line these marks should appear automatically. 如果仅选择几行并按进入命令行,则这些标记应自动出现。

As others have already remarked, the visual selection is represented by the '<,'> range (there's also the :* short form). 正如其他人已经提到的那样,视觉选择由'<,'> 范围表示 (还有:*缩写形式)。 However, as all ranges, this always covers entire lines , even if the selection is only characters or a block. 但是, 作为所有范围,即使选择的只是字符或块,它也始终覆盖整行

Most Ex commands (like :sort ) only operate on full lines, for :substitute , you can limit the effects to the visual selection by including the special \\%V atom in the search pattern, cp. 大多数Ex命令(例如:sort )仅在全行上运行,对于:substitute ,您可以通过在搜索模式cp中包含特殊的\\%V原子来将效果限制为视觉选择。 :help /\\%V . :help /\\%V

The idea to make Ex commands handle blockwise selections is old, but unlikely to be tackled any time soon. 使Ex命令处理按块选择的想法很古老,但不太可能很快解决。

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

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