Friday, July 27, 2012

VI Capitalization

Have you found yourself in the need to either capitalize or de-capitalize a large amount of text, and realized that your text editor did not have that capability, so you proceeded to re-type all of your text in your desired capitalization?

Re-type no more!!! vi will save you, as it has save many others so often before!!

  1. Open your file in vi.
  2. To convert all to uppercase, press gggUG
  3. To convert all to lowercase, press ggguG
  4. Done!
Alternatively, you can type in either of these longer vi commands:
  • <ESC>:%s/.*/\L&/
  • <ESC>:%s/.*/\U&/
though surely variations of these allow you much greater flexibility for more precise and/or complex substitutions.
Enjoy!

And of course, credits due to:


http://www.lefred.be/?q=node/75

No comments:

Post a Comment