简体   繁体   English

Vim 中的 ':list' 和 ':print' 命令的用途是什么?

[英]What is the purpose of the ‘:list’ and ‘:print’ commands in Vim?

Not looking for the help file, more for the motivation why would one use these commands?不寻找帮助文件,更多的是寻找为什么要使用这些命令的动机?

I don't recall ever using :list in over a dozen years of Vim use.我不记得在Vim使用的十几年中使用过:list

:print I use often in this form: :print我经常以这种形式使用:

:g/re/p

Where re is a regular expression.其中re是一个正则表达式。 Handy for seeing where a string appears in a file without having to move through it.方便查看字符串在文件中出现的位置,而无需遍历它。

:list looks neat, though. :list看起来很整洁。 Perhaps I should :s/p/l/ in the previous command.也许我应该在前面的命令中使用:s/p/l/ :-) :-)

I use :print occasionally when I want to print only a chunk of code.当我只想打印一段代码时,我偶尔会使用:print If you have a block of text being visually selected, the command will operate only on what is selected.如果您在视觉上选择了一块文本,则该命令将仅对所选内容进行操作。

The :list command does the same thing, but makes an effort to output things like control characters in a more readable fashion. :list命令做同样的事情,但努力使 output 以更易读的方式控制字符。

I think those are simply old Ex commands, originating from the original vi.我认为这些只是旧的 Ex 命令,源自原始的 vi。 It's useful if you use Ex mode often (see :help Ex-mode ).如果您经常使用 Ex 模式,这很有用(请参阅:help Ex-mode )。 But I use them very seldom.但我很少使用它们。

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

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