Saturday, October 30, 2010

Re: selection to upper case or lower case

Reply to message «selection to upper case or lower case»,
sent 14:16:44 30 October 2010, Saturday
by Jeri Raye:

> With gUU you can change a line to all upper case words.
> With guu you can change a line to all lower case.
>
> How can you apply this to a selection?
> Meaning:
> When I have a piece of code selected to status line shows --SELECT--
> When I then press gUU, it removes my selection and give me the text gUU.
> That's not what I want.
You should not be using select mode instead of visual mode. If you press `gU'
(not `gUU` since second `U' is a motion) in visual mode, it will do what you
want. Try doing `set selectmode=' and then repeat what you do. If you do not
want to use visual mode, use `<C-o>gU' instead of `gU'.

> What I want is to:
> 1) Select a piece of code.
> 2) Press <Shift-F3> and make it upper case.
> 3) Press <Shift-F3> again to change it to lower case. (So a toggle
> function)
If you want to toggle upper/lower (so that `Ul' becomes `uL'), use
vnoremap <special> <S-F3> ~
if you want to toggle upper/lower based on character under cursor, use
vnoremap <expr> <special> <S-F3> ((matchstr(getline('.'), '^.', col('.')-1)=~#'\u')?
('gu'):('gU'))

No comments:

Post a Comment