Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Accidently wrote a command in CAPS LOCK



Peter Stephenson <pws@xxxxxxx> wrote in
news:200606221025.k5MAPD8f010975@xxxxxxxxxxxxxx: 

> zzapper wrote:
>> 
>> Accidently wrote a command in CAPS LOCK
>> 
>> FTX SUCC BOOK
>> 
>> What's the best way to lowercase this?
> 
> Well, going to the start and using down-case-word (ESC l in Emacs
> mode) until you get to the end is the obvious way.
> 
> But it's not hard (after you've worked out the offsets, anyway) to
> write a widget that transforms the region---I hadn't realised there
> wasn't one:
> 
>   down-case-region() {
>     emulate -L zsh
>     integer p1 p2
> 
>     if (( CURSOR < MARK )); then
>       (( p1=CURSOR+1, p2=MARK ))
>     else
>       (( p1=MARK+1, p2=CURSOR ))
>     fi
>     BUFFER[p1,p2]=${(L)BUFFER[p1,p2]}
>   }
>   zle -N down-case-region
> 
> Unfortunately ${(L)...} and parameter indexing don't handle multibyte
> characters yet, so down-case-word, which is implemented internally,
> should be safer.  You could use some kind of hybrid.
> 
I was hoping for a history modifier eg
^^^ or !!:s///
but they don't seem to support wildcards?


-- 
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips



Messages sorted by: Reverse Date, Date, Thread, Author