6

in vim, with

gUw

make the word uppercase, with

guw

make the word lowercase.
how I can convert in one map the upper to lower and the lower to upper?

2 Answers 2

8

If you're trying to invert case, you can use ~. Normally this works only on the selection (e.g. visual mode), but if you want it to be more useful, then :set tildeop so you can do ~w or whatever movement command you like.

4
  • 1
    Thats cool, I didn't know about that one. Unfortunately my brain is already well trained for tilde NOT to act like an operator. Guess I'll stay away from that command... :(
    – dsummersl
    May 2, 2012 at 19:45
  • I always wondered why ~ didn't act like an operator. Adding tildeop. Thanks!
    – mwcz
    May 2, 2012 at 19:45
  • @dsummersi, I only discovered ~ recently, so why would you not want it to act like an operator?
    – Brian
    May 2, 2012 at 19:51
  • 1
    @Brian because it works that way everywhere else. Like in readline, bash etc.
    – sehe
    May 2, 2012 at 22:12
6

You can use the tilde operator with global commands too: g~w

The advantage being, that you can then use the . operator to repeat the operation :)

3
  • in g~w, why g? ~w is the same?
    – JuanPablo
    May 2, 2012 at 19:49
  • 4
    @JuanPablo g~ forces ~ to act as an operator, even if you set notildeop.
    – Neil
    May 2, 2012 at 19:56
  • This was new for me. And full of win. +1
    – sehe
    May 2, 2012 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.