Sunday, January 29, 2012

Re: [vim] Problem with `inoremap jj '

On 2012-01-30, Clark J. Wang wrote:
> On Mon, Jan 30, 2012 at 15:28, Jane Smith wrote:
>
> On 30 Jan 2012, at 07:18, Benjamin R. Haskell wrote:
>
> > On Sun, 29 Jan 2012, Clark J. Wang wrote:
> >
> >> On Monday, January 30, 2012 2:24:55 PM UTC+8, Markus Osterhoff wrote:
> >>>
> >>> * Clark J. Wang [120130 07:01]:
> >>>> So I wonder if the `jj' mapping can be ignored when doing copy-n-paste
> and only work when I'm typing from a keyboard.
> >>> :set paste
> >>> do your paste
> >>> :set nopaste
>
> I am not sure if this is possible or the syntax you would use but could you
> use a mapping to the effect of:
>
> map <c-v> set paste<c-v>set nopaste
>
> You need something to stop the infinite loop and you may want to restrict
> it to insert mode. I think this makes the above mapping into something
> like:
>
> inoremap <c-v> set paste<c-v>set nopaste
>
>
> This should not work I think since vim's <c-v> is not the same as the OS (e.g.
> Windows)'s <c-v>.

That depends on how you have Vim configured. See

:help CTRL-V
:help mswin.vim

That particular mapping does have syntax issues, though. For normal
mode I think it would have to be

:nnoremap <C-V> :set paste<CR>"+gP:set nopaste<CR>

but that's off the top of my head and I haven't tested it. Insert
mode is a little trickier. See the help references for more.

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

No comments:

Post a Comment