How to convert all text to lowercase in Vim

前端 未结 10 1565
刺人心
刺人心 2021-01-29 18:21

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

相关标签:
10条回答
  • 2021-01-29 18:44

    Similar to mangledorf's solution, but shorter and layman friendly

    :%s/.*/\L&/g

    0 讨论(0)
  • 2021-01-29 18:47

    If you are running under a flavor of Unix

    :0,$!tr "[A-Z]" "[a-z]"
    
    0 讨论(0)
  • 2021-01-29 18:48

    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.

    0 讨论(0)
  • 2021-01-29 18:48

    I had a similar issue, and I wanted to use ":%s/old/new/g", but ended up using two commands:

    :0
    gu:$
    
    0 讨论(0)
提交回复
热议问题