Caps Lock

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

Caps Lock

Robert Cussons
Hi all,

don't know how difficult or possible this is to do, but here goes!

I sometimes want to write a large amount of test in capitals so I turn
on Caps Lock, but then I want to use commands and forget that Caps Lock
is on and obviously get unexpected results. Is there a way to get Vim to
ignore Caps Lock when in command mode, but still allow me to press
<shift> + o for example to get O in command mode, with Caps Lock on.
Example to clarify the above:
I am typing away with Caps Lock on, then I enter command mode and want
to put in a blank line above the one I am on, so I want the command for
this to still be <shift> + o, even though I have Caps Lock turned on.
Hope at least someone can understand what I mean!
Thanks,
Rob.
Reply | Threaded
Open this post in threaded view
|

Re: Caps Lock

Dominic Evans
I don't think there is a way to do that. However you could avoid CAPS
LOCK all together...

I don't know if there is already a mark for where insert mode was
started (instead of the manual mp here). But something along the lines
of

mp
i
TYPE TEXT
:'p,'.s/.*/\U&/

would save you have to use caps lock at all (you could bind the latter
substitution to a key)

Regards,
Dom

On 01/11/05, Robert Cussons <[hidden email]> wrote:

> Hi all,
>
> don't know how difficult or possible this is to do, but here goes!
>
> I sometimes want to write a large amount of test in capitals so I turn
> on Caps Lock, but then I want to use commands and forget that Caps Lock
> is on and obviously get unexpected results. Is there a way to get Vim to
> ignore Caps Lock when in command mode, but still allow me to press
> <shift> + o for example to get O in command mode, with Caps Lock on.
> Example to clarify the above:
> I am typing away with Caps Lock on, then I enter command mode and want
> to put in a blank line above the one I am on, so I want the command for
> this to still be <shift> + o, even though I have Caps Lock turned on.
> Hope at least someone can understand what I mean!
> Thanks,
> Rob.
>
Reply | Threaded
Open this post in threaded view
|

Re: Caps Lock

Moshe Kaminsky
In reply to this post by Robert Cussons
Hi,

* Robert Cussons <[hidden email]> [01/11/05 12:29]:

>
> Hi all,
>
> don't know how difficult or possible this is to do, but here goes!
>
> I sometimes want to write a large amount of test in capitals so I turn on
> Caps Lock, but then I want to use commands and forget that Caps Lock is on
> and obviously get unexpected results. Is there a way to get Vim to ignore
> Caps Lock when in command mode, but still allow me to press <shift> + o for
> example to get O in command mode, with Caps Lock on. Example to clarify the
> above:
> I am typing away with Caps Lock on, then I enter command mode and want to put
> in a blank line above the one I am on, so I want the command for this to
> still be <shift> + o, even though I have Caps Lock turned on.
> Hope at least someone can understand what I mean!
Maybe instead of pressing Caps, you should :imap any non capital letter
to a capital one. Then, when you are done, unmap it. All this should be
done by a suitable command, of course.

Moshe
> Thanks,
> Rob.
>


--
I love deadlines. I like the whooshing sound they make as they fly by.
                                        -- Douglas Adams
   
    Moshe Kaminsky <[hidden email]>
    Home: 08-9456841


attachment0 (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Caps Lock

Tim Chase-2
In reply to this post by Dominic Evans
> I don't think there is a way to do that. However you could
> avoid CAPS LOCK all together...
[snip]
> mp
> i
> TYPE TEXT
> :'p,'.s/.*/\U&/

Well, there's also visually highlighting the text and pressing
"U" to force the selected text to be highlighted.

Additionally, if it's all a paragraph (delineated by blank lines
above and below), you can use

        gUip

to uppercase the entire paragraph.  If it's just a sentence
(":help sentence"), you can use

        gUis

Or for that matter, any other text object or motion should do
just fine with the "gU" command.

        :help gU
        :he is
        :he ip
        :he text-objects

for some pointers on these.

-tim





Reply | Threaded
Open this post in threaded view
|

Re: Caps Lock

John (Eljay) Love-Jensen
In reply to this post by Robert Cussons
Hi Rob,

I usually disable Caps Lock altogether, in the OS.  (Windows, OS X, Amiga
OS.)

Or remap Caps Lock to Control.

Or use a Happy Hacking Keyboard Lite 2 (USB).

HTH,
--Eljay

Reply | Threaded
Open this post in threaded view
|

Re: Caps Lock

Dominic Evans
In reply to this post by Dominic Evans
On 01/11/05, Keith W. Roberts <[hidden email]> wrote:

> ----Original Message----
> From: Dominic Evans [mailto:[hidden email]]
> Sent: Tuesday, November 01, 2005 2:43 AM
> To: [hidden email]
> Cc: [hidden email]
> Subject: Re: Caps Lock
>
> > I don't think there is a way to do that. However you could avoid CAPS
> > LOCK all together...
> >
> > I don't know if there is already a mark for where insert mode was
> > started (instead of the manual mp here).
>
> '[,'] is the range for the most recent insertion (or yank, whichever is
> later).  These maps will let you upcase the prior (or current) insertion:
>
> nnoremap <F12> `[gU`]
> inoremap <F12> <ESC>`[gU`]
>

Ah `[ and `].

However, the latter one seems to be non-inclusive and miss off the
last typed character. The following worked:

`[gU'.

Cheers,
Dom
Reply | Threaded
Open this post in threaded view
|

Re: Caps Lock

Hari Krishna Dara
In reply to this post by Robert Cussons

On Tue, 1 Nov 2005 at 12:49pm, Moshe Kaminsky wrote:

> Hi,
>
> * Robert Cussons <[hidden email]> [01/11/05 12:29]:
> >
> > Hi all,
> >
> > don't know how difficult or possible this is to do, but here goes!
> >
> > I sometimes want to write a large amount of test in capitals so I turn on
> > Caps Lock, but then I want to use commands and forget that Caps Lock is on
> > and obviously get unexpected results. Is there a way to get Vim to ignore
> > Caps Lock when in command mode, but still allow me to press <shift> + o for
> > example to get O in command mode, with Caps Lock on. Example to clarify the
> > above:
> > I am typing away with Caps Lock on, then I enter command mode and want to
put
> > in a blank line above the one I am on, so I want the command for this to
> > still be <shift> + o, even though I have Caps Lock turned on.
> > Hope at least someone can understand what I mean!
>
> Maybe instead of pressing Caps, you should :imap any non capital letter
> to a capital one. Then, when you are done, unmap it. All this should be
> done by a suitable command, of course.
>

Yep, that is what came into my mind too. You should really use a "soft"
version of capslock, implemented in Vim. Something like to start with:

function! ToggleCaps()
  if !exists('g:capslock')
    let g:capslock = 0
  endif
  let lc=char2nr('a')
  let diff=lc - char2nr('A')
  let c = lc
  while c < (lc+26)
    if !g:capslock
      exec 'inoremap' nr2char(c) nr2char(c-diff)
    else
      exec 'iunmap' nr2char(c)
    endif
    let c = c + 1
  endwhile
  let g:capslock = !g:capslock
endfunction
nnoremap <silent> \cl :call ToggleCaps()<CR>:echo "Caps lock is
".(g:capslock?"ON":"OFF")<CR>

Extending this to all keys would require more sohisticated mapping.

--
HTH,
Hari


       
               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com