如何将Vim中的所有文本转换为小写?这可能吗?


当前回答

If you really mean small caps, then no, that is not possible – just as it isn’t possible to convert text to bold or italic in any text editor (as opposed to word processor). If you want to convert text to lowercase, create a visual block and press u (or U to convert to uppercase). Tilde (~) in command mode reverses case of the character under the cursor. If you want to see all text in Vim in small caps, you might want to look at the guifont option, or type :set guifont=* if your Vim flavour supports GUI font chooser.

其他回答

如果您在某种Unix系统下运行

:0,$!tr "[A-Z]" "[a-z]"

我假设你想要小写的文本。解决方法很简单:

ggVGu

解释:

Gg -指向文本的第一行 V -打开视觉选择,在直线模式下 G -转到文件的结尾(此时你已经选择了整个文本) 小写的选定区域

使用ggguG

Gg:到第一行。

Gu:小写。

G:排到最后一行。

用g~切换大小写“HellO”到“HellO”,然后移动。 大写的“HellO”到“HellO”加上gU然后移动。 小写的“HellO”到“HellO”加上gu然后一个动作。

有关例子和更多信息,请阅读以下内容: http://vim.wikia.com/wiki/Switching_case_of_characters

If you really mean small caps, then no, that is not possible – just as it isn’t possible to convert text to bold or italic in any text editor (as opposed to word processor). If you want to convert text to lowercase, create a visual block and press u (or U to convert to uppercase). Tilde (~) in command mode reverses case of the character under the cursor. If you want to see all text in Vim in small caps, you might want to look at the guifont option, or type :set guifont=* if your Vim flavour supports GUI font chooser.