Home


      There Are 10 Types of People in the World....
Home
















Percona Live MySQL Conference and Expo, April 22-25, 2013

lefred sprl

Looking for an IT consultant in Open Source ?

VAT: BE0835.956.787

Contact: info at lefred dot be

Home

Tip: vi and lowercase/uppercase

Submitted by lefred on Thu, 01/10/2008 - 13:32

As always I use my blog as reminder of some useful commands or tips.

This one is for dimi, to change the case of a full document in vi, use the following command to transform everything in lowercase :


<ESC>:%s/.*/\L&/

and in uppercase :

<ESC>:%s/.*/\U&/

I hope this helps ;)

  • Add new comment
  • Share this
Tags:
  • GNU/Linux
  • Tips and tricks

12 reponses to "Tip: vi and lowercase/uppercase"

Jeffrey Nimer's picture

1. Good tips, an easier

Submitted by Jeffrey Nimer (not verified) on Thu, 12/27/2012 - 00:22.

Good tips, an easier technique so far. A quick help that covers all of the important commands. - Jeffrey Nimer

  • reply
Anonymous's picture

2. Very useful . Thanks a lot

Submitted by Anonymous (not verified) on Wed, 12/05/2012 - 12:19.

Very useful . Thanks a lot :-)

  • reply
Karthik's picture

3. Thanks this helps :)

Submitted by Karthik (not verified) on Wed, 03/28/2012 - 16:06.

Thanks this helps :)

  • reply
Anonymous's picture

4. Thank you

Submitted by Anonymous (not verified) on Fri, 12/16/2011 - 01:35.

It is neat stuff

  • reply
Anonymous's picture

5. thanks

Submitted by Anonymous (not verified) on Mon, 01/10/2011 - 15:31.

Simple tip, but it juste saved my day :D

Thanks alot!

  • reply
advexiatred's picture

6. Help! Need driver for phillips wireless pcmcia card.

Submitted by advexiatred (not verified) on Wed, 04/08/2009 - 15:32.

I need a driver for my phillips snn6500 wireless netcard
or smc2632 wireless net card.
I can`t make them run on linpus linux lite.

Please help.

Regards,
VadeDromaro

  • reply
Anonymous's picture

7. might be easier...

Submitted by Anonymous on Mon, 01/14/2008 - 15:47.

for uppercase: gggUG
for lowercase: ggguG

PS: the first 2 g's are for moving to the beginning of the document.
PS2: works in vim, don't know about plain vi

  • reply
Anonymous's picture

8. Anonymous is right!

Submitted by Anonymous (not verified) on Wed, 01/14/2009 - 18:09.

so just wanted to break down that last post so people know what's up with it.

the first 2 'g's put your cursor to the beginning of the file. the 3rd g puts you in what appears to be a "replace" mode of some kind. U means uppercase (or u means lowercase) the final G means until the end of the file.

So if you want to manipulate just a single word you should move the cursor to the beginning of the word then type gUw ((g)replace to (U)uppercase until (w)the end of the word).

Or if you want to go from the current position to the end of the line gU$ ((g)replace to (U)uppercase until ($)the end of the line).

Or if you want to go from the current position to the next 'x' on the line gUtx ((g) replace to (U) uppercase (t) to (x) the x character)... Of course you can replace x with any character you want.

Figured that might help those who don't know about jumping around in a file.

(also if you only want to do the current line and the next two lines: gU2).

This stuff is handy!

  • reply
Anonymous's picture

9. that last one in brackets there...

Submitted by Anonymous (not verified) on Wed, 01/14/2009 - 18:11.

was supposed to be gU2<down arrow>

  • reply
Liz's picture

10. the 3rd "g"

Submitted by Liz (not verified) on Wed, 01/21/2009 - 22:58.

You can think of the third "g" as "global"... as in "apply this to the whole file".

  • reply
Pibe's picture

11. To my understanding, "apply

Submitted by Pibe (not verified) on Thu, 02/09/2012 - 16:17.

To my understanding, "apply to the Whole file" is done by the last 'G' not the 3rd 'g'.
the 'G' means "till the end of the document".

The 3rd 'g' would mean "apply to all characters" and may be replace by a regexp, no?

  • reply
udaman's picture

12. Very clear

Submitted by udaman (not verified) on Tue, 03/16/2010 - 17:03.

I didn't know what the 3rd g meant. Now I know. Thanks!

  • reply

twitter

Tweets by @lefred

Recent comments

  • Thanks a lot
    3 weeks 2 days ago
  • x86_64 preferably.
    3 weeks 2 days ago
  • imspector for CentOS 6.3?
    3 weeks 2 days ago
  • I love free software. Happy
    4 weeks 13 hours ago
  • I always have the same
    4 weeks 18 hours ago
  • Hahaha you have got to be
    4 weeks 2 days ago
  • This has been a great help!
    4 weeks 2 days ago
  • Where is that located? I have
    4 weeks 4 days ago
  • Finally i found a nice
    4 weeks 4 days ago
  • This helped a lot! I've been
    4 weeks 4 days ago

Locations of visitors to this page

I love Smashing Magazine!
Fervens Drupal theme by Leow Kah Thong. Designed by Design Disease and brought to you by Smashing Magazine.
Generated on the new server.