sinbad | 8 Aug 2012 08:05
Picon

capitalize the current word in insert mode

how can one capitalize the current word or the 
word just before the current cursor position 
with out leaving the insert mode ? leaving insert
mode and capitalize and come back to insert mode
is becoming a tedious task for me ...:)

tia

--

-- 
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

Paul Isambert | 8 Aug 2012 09:10
Picon
Favicon

Re: capitalize the current word in insert mode

sinbad <sinbad.sinbad <at> gmail.com> a écrit:
> 
> how can one capitalize the current word or the 
> word just before the current cursor position 
> with out leaving the insert mode ? leaving insert
> mode and capitalize and come back to insert mode
> is becoming a tedious task for me ...:)

A simple remap, perhaps:

  :inoremap <C-U> <Esc>gUawea

Best,
Paul

--

-- 
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

Tim Chase | 8 Aug 2012 12:53

Re: bug in i_CTRL-\_CTRL-u? (was "capitalize the current word in insert mode")

On 08/08/12 01:05, sinbad wrote:
> how can one capitalize the current word or the 
> word just before the current cursor position 
> with out leaving the insert mode ? leaving insert
> mode and capitalize and come back to insert mode
> is becoming a tedious task for me ...:)

In attempting to answer sinbad's question, I figured it was the
perfect opportunity for i_CTRL-\_CTRL-u which is described as "like
CTRL-O but don't move the cursor".  So I created a mapping:

  :inoremap ~ <c-bslash><c-o>gUB

yet if I insert "This is a test~" (expecting it to change it to
"This is a TEST" with the cursor where it started after "test") it
changes where my insertion point is.  Are others seeing this too?
Is this a bug or my misunderstanding of i_CTRL-\_CTRL-u?

-tim

PS: to the OP, you can use

  :inoremap <f4> <esc>gUiwgi

which is just these 3 bits together:

:help gU
:help iw
:help gi

(Continue reading)

Christian Brabandt | 8 Aug 2012 13:19

Re: bug in i_CTRL-\_CTRL-u? (was "capitalize the current word in insert mode")

Hi Tim!

On Mi, 08 Aug 2012, Tim Chase wrote:

> In attempting to answer sinbad's question, I figured it was the
> perfect opportunity for i_CTRL-\_CTRL-u which is described as "like
> CTRL-O but don't move the cursor".  So I created a mapping:
> 
>   :inoremap ~ <c-bslash><c-o>gUB
> 
> yet if I insert "This is a test~" (expecting it to change it to
> "This is a TEST" with the cursor where it started after "test") it
> changes where my insertion point is.  Are others seeing this too?
> Is this a bug or my misunderstanding of i_CTRL-\_CTRL-u?

This is a misunderstanding on your side. What i_Ctrl-\_Ctrl-O does (I 
assume you mean 'o' and not 'u'?), is it doesn't move the cursor when 
entering temporary normal mode like Ctrl-O does (e.g. it steps the 
cursor back by one char, like ESC does).

But of course you can still move the cursor using a normal mode command. 
And then the cursor will stay there.

Mit freundlichen Grüßen
Christian
-- 

--

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
(Continue reading)

Tim Chase | 8 Aug 2012 13:33

Re: not a bug in i_CTRL-\_CTRL-o (was "capitalize the current word in insert mode")

On 08/08/12 06:19, Christian Brabandt wrote:
> On Mi, 08 Aug 2012, Tim Chase wrote:
>>   :inoremap ~ <c-bslash><c-o>gUB
>
> This is a misunderstanding on your side. What i_Ctrl-\_Ctrl-O does (I 
> assume you mean 'o' and not 'u'?),

Doh, yes...type it once wrong and copy/paste elsewhere and it just
makes me look like an idiot :)

> is it doesn't move the cursor when entering temporary normal mode
> like Ctrl-O does (e.g. it steps the cursor back by one char, like
> ESC does).
> 
> But of course you can still move the cursor using a normal mode
> command. And then the cursor will stay there.

Ah, okay.  I'd (mis)understood it as "I want to issue one
normal-mode command and regardless of what happens, the cursor
should remain where it is currently", not "don't move the cursor
back one character"

-tim

--

-- 
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

(Continue reading)

Christian Brabandt | 8 Aug 2012 13:41

Re: not a bug in i_CTRL-\_CTRL-o (was "capitalize the current word in insert mode")

Hi Tim!

On Mi, 08 Aug 2012, Tim Chase wrote:

> On 08/08/12 06:19, Christian Brabandt wrote:
> > On Mi, 08 Aug 2012, Tim Chase wrote:
> >>   :inoremap ~ <c-bslash><c-o>gUB
> >
> > This is a misunderstanding on your side. What i_Ctrl-\_Ctrl-O does (I 
> > assume you mean 'o' and not 'u'?),
> 
> Doh, yes...type it once wrong and copy/paste elsewhere and it just
> makes me look like an idiot :)

The fact, that I guessed your key correctly means, I suspected a 
copy-paste error.

> > is it doesn't move the cursor when entering temporary normal mode
> > like Ctrl-O does (e.g. it steps the cursor back by one char, like
> > ESC does).
> > 
> > But of course you can still move the cursor using a normal mode
> > command. And then the cursor will stay there.
> 
> Ah, okay.  I'd (mis)understood it as "I want to issue one
> normal-mode command and regardless of what happens, the cursor
> should remain where it is currently", not "don't move the cursor
> back one character"

Here is your chance to improve the documentation. I am sure Bram happily 
(Continue reading)

raoulmillais | 8 Aug 2012 12:20
Favicon
Gravatar

Re: capitalize the current word in insert mode

On Wednesday, August 8, 2012 7:05:16 AM UTC+1, sinbad wrote:
> how can one capitalize the current word or the 
> word just before the current cursor position 
> with out leaving the insert mode ? leaving insert
> mode and capitalize and come back to insert mode
> is becoming a tedious task for me ...:)
> 
> tia

Assuming you're in normal mode, you can visually select the word then use the ~ command to switch the case:

viw~

--

-- 
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

Chris Jones | 8 Aug 2012 16:25
Picon

Re: capitalize the current word in insert mode

On Wed, Aug 08, 2012 at 02:05:16AM EDT, sinbad wrote:

> how can one capitalize the current word or the word just before the
> current cursor position with out leaving the insert mode ? leaving
> insert mode and capitalize and come back to insert mode is becoming
> a tedious task for me ...:)

I hardly ever capitalize entire words (with the possible exception of
shell/environment variables), but since you know you are going to stay
in insert mode, wouldn't this be a clear case of using the CapsLk key..
or imap some keyboard action to toggle an ‘allcaps’ keymap if you don't
have one on your keyboard..?

CJ

-- 
HOW ARE YOU GENTLEMEN?

--

-- 
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


Gmane