Mapping does not work

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

Mapping does not work

J.A.J. Pater

Dear vim users,

One way or another a mapping I'm trying to implement doesn't work.
I'm trying to paste with CTRL-V only in insert mode and keep using
CTRL-V for visual in other modes.

In my .vimrc I've got:

imap <C-V> "+gP

The only thing I get when pushing CTRL-V in insert mode is the literal
text "+gP
But not the desired effect: pasting.

I tried with inoremap also, but to no avail.

What could be wrong?

Adriaan.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mapping does not work

meino.cramer

J.A.J. Pater <[hidden email]> [09-07-31 19:10]:

>
> Dear vim users,
>
> One way or another a mapping I'm trying to implement doesn't work.
> I'm trying to paste with CTRL-V only in insert mode and keep using
> CTRL-V for visual in other modes.
>
> In my .vimrc I've got:
>
> imap <C-V> "+gP
>
> The only thing I get when pushing CTRL-V in insert mode is the literal
> text "+gP
> But not the desired effect: pasting.
>
> I tried with inoremap also, but to no avail.
>
> What could be wrong?
>
> Adriaan.
>
>
Hi,

just a shot in the dark....

Try

    imap <C-V> normal "+gP

instead.

Fingers crossed...

Have a nice weekend!
mcc

--
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mapping does not work

Charles Campbell
In reply to this post by J.A.J. Pater

J.A.J. Pater wrote:

> One way or another a mapping I'm trying to implement doesn't work.
> I'm trying to paste with CTRL-V only in insert mode and keep using
> CTRL-V for visual in other modes.
>
> In my .vimrc I've got:
>
> imap <C-V> "+gP
>
> The only thing I get when pushing CTRL-V in insert mode is the literal
> text "+gP
> But not the desired effect: pasting.
>
> I tried with inoremap also, but to no avail.
>
> What could be wrong?
>  
The imap takes effect during insert mode; it does not, by itself, change
modes.  In other
words, the "+gP is acting like keys that you type.  Obviously, what you
want is what
"+gP does in normal mode; hence, your imap needs to leave insert mode
and enter
normal mode.  Turns out there's a convenient one-shot insert-mode
command for that
(ctrl-o):

imap <c-v>  <c-o>"+gP

Regards,
Chip Campbell


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mapping does not work

J.A.J. Pater
In reply to this post by meino.cramer

[hidden email] schreef:

>> I'm trying to paste with CTRL-V only in insert mode and keep using
>> CTRL-V for visual in other modes.
>>
>> In my .vimrc I've got:
>>
>> imap <C-V> "+gP
>>
>> The only thing I get when pushing CTRL-V in insert mode is the literal
>> text "+gP
>> But not the desired effect: pasting.
>>
>> I tried with inoremap also, but to no avail.
>>
>> What could be wrong?
>>
>>    
Thanks meino,

But now I just get the text: normal "+gP

Trying the command "+gP in insert mode gives: gP (not the desired paste
effect)

Since I'm using gvim selecting "+gP via the menu does work!

I'm in the dark, so keep shooting, maybe we'll hit something.

Adriaan

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mapping does not work

J.A.J. Pater
In reply to this post by Charles Campbell
Charles Campbell schreef:
J.A.J. Pater wrote:
  
One way or another a mapping I'm trying to implement doesn't work.
I'm trying to paste with CTRL-V only in insert mode and keep using 
CTRL-V for visual in other modes.

In my .vimrc I've got:

imap <C-V> "+gP

The only thing I get when pushing CTRL-V in insert mode is the literal 
text "+gP
But not the desired effect: pasting.

I tried with inoremap also, but to no avail.

What could be wrong?
  
    
The imap takes effect during insert mode; it does not, by itself, change 
modes.  In other
words, the "+gP is acting like keys that you type.  Obviously, what you 
want is what
"+gP does in normal mode; hence, your imap needs to leave insert mode 
and enter
normal mode.  Turns out there's a convenient one-shot insert-mode 
command for that
(ctrl-o):

imap <c-v>  <c-o>"+gP

Regards,
Chip Campbell
Much to learn I have...
That did it!
Thanks very, very much Chip!




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Mapping does not work

Tony Mechelynck
In reply to this post by Charles Campbell

On 31/07/09 20:07, Charles Campbell wrote:

>
> J.A.J. Pater wrote:
>> One way or another a mapping I'm trying to implement doesn't work.
>> I'm trying to paste with CTRL-V only in insert mode and keep using
>> CTRL-V for visual in other modes.
>>
>> In my .vimrc I've got:
>>
>> imap<C-V>  "+gP
>>
>> The only thing I get when pushing CTRL-V in insert mode is the literal
>> text "+gP
>> But not the desired effect: pasting.
>>
>> I tried with inoremap also, but to no avail.
>>
>> What could be wrong?
>>
> The imap takes effect during insert mode; it does not, by itself, change
> modes.  In other
> words, the "+gP is acting like keys that you type.  Obviously, what you
> want is what
> "+gP does in normal mode; hence, your imap needs to leave insert mode
> and enter
> normal mode.  Turns out there's a convenient one-shot insert-mode
> command for that
> (ctrl-o):
>
> imap<c-v>   <c-o>"+gP
>
> Regards,
> Chip Campbell

Indeed. Alternately, to insert the clipboard (register +) at the cursor
in Insert mode, you could also use Ctrl-R + (see ":help i_CTRL-R"), so
the following would also work:

        imap <C-V> <C-R>+

However, if you use <C-V> as the {lhs} of _any_ Insert-mode mapping, be
aware that whenever you're told to use Ctrl-V in Insert or Command-line
modes to enter a character code either literally or by its decimal,
octal or hex value (see ":help i_CTRL-V" and ":help i_CTRL-V_digit),
you'll have to use Ctrl-Q instead, which might not work if you're in
Console mode in a terminal which uses Xon/Xoff pause & restart.


Best regards,
Tony.
--
Brain fried -- Core dumped

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---