Why I'm not switching to command mode?

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

Why I'm not switching to command mode?

Alex Kostikov
I want Ctrl+C to copy selected text to clipboard and switch to command
mode.
The line bellow populates clipboard but doesn't do the switching to
command mode. Why?

vnoremap <C-c> "+y<ESC>

-- Alexander

--
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: Why I'm not switching to command mode?

Alex Kostikov
After some retries I figure out command that does the thing I want:

snoremap <C-C> <ESC>gv"*ygv<ESC>

Few lessons learned:
1) if vnoremap is used I'm not able to return to command mode for some reason
2) first esc goes to command mode
3) gv restores selection and goes to the visual mode
4) "*y copies selection to windows clipboard
5) second gv<ESC> is used to go to command mode with preserving cursor position.

The question is - could this command be written easier?

-- Alexander


On Tue, Nov 29, 2011 at 1:02 PM, Alex Kostikov <[hidden email]> wrote:

> I want Ctrl+C to copy selected text to clipboard and switch to command
> mode.
> The line bellow populates clipboard but doesn't do the switching to
> command mode. Why?
>
> vnoremap <C-c> "+y<ESC>
>
> -- Alexander
>
>



--
Alexander Kostikov

--
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: Why I'm not switching to command mode?

Jean-Rene David-2
* Alexander Kostikov [2011.11.29 21:40]:
> After some retries I figure out command that does the thing I want:
>
> snoremap <C-C> <ESC>gv"*ygv<ESC>
>
> Few lessons learned:
> 1) if vnoremap is used I'm not able to return to command mode for some reason

There is no "command" mode in vim. One may think
you are referring to "command-line" mode, but you
seem to be referring to "normal" mode. That's the
mode where h,j,k,l move the cursor around in the
text.

If you don't return to normal mode after your
original command, what mode *are* you in?

> The question is - could this command be written
> easier?

Sure.

:vnoremap <c-c> "*y`>

--
JR

--
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: Why I'm not switching to command mode?

Benjamin Fritz


On Nov 30, 7:45 pm, Jean-Rene David <[hidden email]> wrote:

> * Alexander Kostikov [2011.11.29 21:40]:
>
> > After some retries I figure out command that does the thing I want:
>
> > snoremap <C-C> <ESC>gv"*ygv<ESC>
>
> > Few lessons learned:
> > 1) if vnoremap is used I'm not able to return to command mode for some reason
>
> There is no "command" mode in vim. One may think
> you are referring to "command-line" mode, but you
> seem to be referring to "normal" mode. That's the
> mode where h,j,k,l move the cursor around in the
> text.
>

command mode is another (rarely used) name for normal mode. I made the
same mistake a while back on this same list.

:help command-mode

--
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: Why I'm not switching to command mode?

Benjamin Fritz
In reply to this post by Alex Kostikov


On Nov 29, 3:02 pm, Alex Kostikov <[hidden email]> wrote:
> I want Ctrl+C to copy selected text to clipboard and switch to command
> mode.
> The line bellow populates clipboard but doesn't do the switching to
> command mode. Why?
>
> vnoremap <C-c> "+y<ESC>
>

This works for me, except that it beeps at me. The reason it beeps at
me, is that the 'y' operator in visual mode already returns to command/
normal mode automatically, making the final <Esc> redundant.

If you're expecting to still be in visual mode after a "+y, then
perhaps you're running with 'insertmode' set? Or in "easy" mode? If
'insertmode' is set, Vim is usually in insert mode instead of command/
normal mode, and rather than using <Esc> to go to command/normal mode,
you use <C-L>.

--
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: Why I'm not switching to command mode?

Jean-Rene David-2
In reply to this post by Benjamin Fritz
* Ben Fritz [2011.11.30 23:40]:
> On Nov 30, 7:45 pm, Jean-Rene David <[hidden email]> wrote:
> > There is no "command" mode in vim.
>
> command mode is another (rarely used) name for normal mode. I made the
> same mistake a while back on this same list.
>
> :help command-mode

I stand corrected.

--
JR

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