On 2012-08-01, Rodrigo Gurgel wrote:
> I want to map a Shift + Insert, as I usually paste code for
> studing (or even take some of forum's questions to prepare an
> answer). But as mapped for .cpp and .h the pasted code appears
> messed up.
> 
> Example:
> 
> 1  class A {
> 2 }
> 3 public:
> 4     class B {
> 5     }
> 6             // ...
> 7             //     };
> 8             //         static void f();
> 9             //             // ...
> 10             //             };
> 11             //             )
> 
> Original code:
> 
> class A {
> public:
>     class B {
>         // ...
>     };
>     static void f();
>     // ...
> };
> 
> To avoid this is necessary to run :set paste.
> 
> So, the question is, how to map a Shift + Insert, just like imap
> <S-Insert> <Esc>:set paste<CR>i and very here pass foward the
> Shift + Insert to its natural behavior, that is pasting and then
> turn back and set :set paste! back?
> 
> Obs.: { is mapped to break line and put and ending }, along with
> that kind of maps the pasted text will be messed up.

I started to suggest using :inoremap to define your mapping since
that will ignore any mappings of keys used on the rhs of the
mapping.  However, as I was verifying the problem I discovered that
the problem doesn't exist for me.  Starting Vim like this,

    "C:\Program Files\vim\vim73\gvim.exe" -u NONE -i NONE

and executing either

    :set ai

or

    :filetype indent on
    :set ft=cpp

before pasting your original code using <S-Insert> resulted in
the same indentation as the original code.  This was using Vim
7.3.600 on Windows XP.

I think something in your configuration is causing the problem.

    :help <S-Insert>

says that that keycode is already mapped to

    <C-R><C-O>*

(which I verified) and

    :help i_CTRL-R_CTRL-O

says that that command inserts the contents of a register literally
and without auto-indenting.

So, you shouldn't be seeing any auto-indenting when you paste with
<S-Insert>.  What do you see when you execute

    :imap <S-Insert>

?

Regards,
Gary

-- 
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 via email to