How to convert all text to lowercase in Vim

2019-03-07 20:34发布

How do you convert all text in Vim to lowercase? Is it even possible?

10条回答
不美不萌又怎样
2楼-- · 2019-03-07 21:09
  • Toggle case "HellO" to "hELLo" with g~ then a movement.
  • Uppercase "HellO" to "HELLO" with gU then a movement.
  • Lowercase "HellO" to "hello" with gu then a movement.

For examples and more info please read this: http://vim.wikia.com/wiki/Switching_case_of_characters

查看更多
叼着烟拽天下
3楼-- · 2019-03-07 21:12

Many ways to skin a cat... here's the way I just posted about:


:%s/[A-Z]/\L&/g

Likewise for upper case:


:%s/[a-z]/\U&/g

I prefer this way because I am using this construct (:%s/[pattern]/replace/g) all the time so it's more natural.

查看更多
趁早两清
4楼-- · 2019-03-07 21:16

I assume you want lowercase the text. Solution is pretty simple:

ggVGu

Explanation:

  1. gg - goes to first line of text
  2. V - turns on Visual selection, in line mode
  3. G - goes to end of file (at the moment you have whole text selected)
  4. u - lowercase selected area
查看更多
放我归山
5楼-- · 2019-03-07 21:16

use this command mode option

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.
查看更多
登录 后发表回答