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


当前回答

使用此命令模式选项

ggguG


gg - Goto the first line 
g  - start to converting from current line    
u  - Convert into lower case for all characters
G  - To end of the file.

其他回答

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

ggVGu

解释:

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

我有一个类似的问题,我想使用“:%s/old/new/g”,但最终使用了两个命令:

:0
gu:$

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.

类似于mangledorf的解决方案,但更简短,对外行更友好

: % s / . * \ l / g

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

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