selection to upper case or lower case

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

selection to upper case or lower case

Jeri Raye
Hi,

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.

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)


Rgds,
Jeri

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: selection to upper case or lower case

Nikolay Aleksandrovich Pavlov
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'))

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: selection to upper case or lower case

Javier Rojas-4
On Sat, Oct 30, 2010 at 02:38:21PM +0400, ZyX wrote:

> Reply to message «selection to upper case or lower case»,
> > 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'))
If I remember correctly, keybindings like Shift-Fn are recognized only
by gvim, not by terminal vim (because of limitations of the terminal
emulator, e.g., xterm or konsole)

Using ~ to toggle the case of text seems more simple to type for me.

--
Javier Rojas

GPG Key ID: 0x24E00D68

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: selection to upper case or lower case

Nikolay Aleksandrovich Pavlov
Reply to message «Re: selection to upper case or lower case»,
sent 17:49:57 30 October 2010, Saturday
by Javier Rojas:

> If I remember correctly, keybindings like Shift-Fn are recognized only
> by gvim, not by terminal vim (because of limitations of the terminal
> emulator, e.g., xterm or konsole)
No, sometimes <S-FN> works fine. Sometimes it requires a bunch of
    ...
    set <S-F3>=^[[13;2~
    ...
placed in the vimrc. But they can be recognized in a terminal. There can be some
problems when terminal takes <S-FN> key as its own shortcut... but this can
apply to any <C-, <A- and others as well.

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: selection to upper case or lower case

Jeri Raye
In reply to this post by Nikolay Aleksandrovich Pavlov
>> 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--

This seems to work for the text selected when your in select mode
vmap <S-F3> <esc>gv~

<esc> stops the select-mode
gv selects the last selection, but then in visual mode
~ does then the toggling

Rgds,
Jeri

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php