From: Ralf Goertz on
Ant wrote:

> Using the tilde key in VI allows me to change the case of a letter.
>
> Using the period key allows me to repeat the change for subsequent
> letters of a word.
>
> Is there a (more elegant) way to uppercase one word?

I alway use "g~w" in vim. See ":help g~"
From: Geoff Clare on
Ant wrote:

> Using the tilde key in VI allows me to change the case of a letter.
>
> Using the period key allows me to repeat the change for subsequent
> letters of a word.
>
> Is there a (more elegant) way to uppercase one word?

As others have posted, there are ways in nvi and vim. However,
since you posted to comp.unix.shell here are some macros that do it
using only POSIX functionality. These have been in my .exrc for
over 20 years (from the days when the only vi available to me was
the "real" one).

This is the output from "cat -v", so ^V is CTRL-V, ^[ is ESC, etc.

" =y, =Y macros - yank word (Word) onto line by itself: 2=y works
" (side effect - mark current position as `x)
map =y deumxO^[p
map =Y dEumxO^[p
"
" \R macro - common part of \l, etc. (overwrites text at `x with current line)
map \R A^V^V^[^[0iR^["xDdd`x@x`x
"
" =l macro - change upper to lower case over whole line
map =l :s/.*/\L&/^M
" \l (\L) macro - change upper to lower case over one word (Word): 2\l works
map \l =y=l\R
map \L =Y=l\R
"
" =u macro - change lower to upper case over whole line
map =u :s/.*/\U&/^M
" \u (\U) macro - change lower to upper case over one word (Word): 2\u works
map \u =y=u\R
map \U =Y=u\R
"
" =x macro - exchange case over whole line (slow if showmatch set)
map =x :s/\([a-z]*\)\([A-Z]*\)/\U\1\L\2/g^M
" \x (\X) macro - exchange case over one word (Word): 2\x works
map \x =y=x\R
map \X =Y=x\R

--
Geoff Clare <netnews(a)gclare.org.uk>


From: Antony Scriven on
On 8 Apr, 01:12, Seebs wrote:

> On 2010-04-07, Ant <a...(a)example.com> wrote:
>
> > Using the tilde key in VI allows me to change the case
> > of a letter.
>
> > Using the period key allows me to repeat the change for
> > subsequent letters of a word.
>
> > Is there a (more elegant) way to uppercase one word?
>
> Use nvi and set tildeop, then do "~e" from the first
> letter of the word.
>
> (This kind of thing is why I consider nvi "the one true
> vi".)

Well since you can do that in vim, and since vim in
compatible behaves more like vi than nvi does ... --Antony
From: Seebs on
On 2010-04-08, Chris Ahlstrom <ahlstromc(a)launchmodem.com> wrote:
> You can set tildeop in vim, also.

Ooh! Now if only it had the other stuff I'm used to. (In particular, I'd
kill for a setting for "do infinite undo the way nvi does", because I find
that more intuitive.)

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: John DuBois on
In article <hpj435$vmi$1(a)air.soe.uq.edu.au>, Ant <ant(a)example.com> wrote:
>Using the tilde key in VI allows me to change the case of a letter.
>
>Using the period key allows me to repeat the change for subsequent
>letters of a word.
>
>Is there a (more elegant) way to uppercase one word?

From my .exrc as it existed 22 years ago.
<esc> is a literal escape; ^V is a literal control-V.

" change word to lower case
map #3 i^V
<esc>Ea^V
<esc>k:s/.*/\L&/^V
JkJ
" change word to upper case
map #4 i^V
<esc>Ea^V
<esc>k:s/.*/\U&/^V
JkJ


John
--
John DuBois spcecdt(a)armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: very strange ksh behavior
Next: problems with loop in bash