Don't load specific keymap when pasting

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Don't load specific keymap when pasting

Steve
Hello,

I have these line in ~/.vim/keymap/touchesfr.vim

loadkeymap
« «<Char-0xa0>
» <Char-0xa0>»
? <Char-0xa0>?
! <Char-0xa0>!
: <Char-0xa0>:
; <Char-0xa0>;

because in French you need a non-breaking space before or after a double
punctuation. Works great when editing text. But I often want to
copy-paste an URL and if it contains one of those double punctuation,
I'll end with <Char-0xa0> in it. So I'll have to manually delete it
which is rather annoying.

So the question is how could I do to not have this behaviour when
copy-pasting?


Thank you

Steve


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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Don't load specific keymap when pasting

Christian Brabandt

On Fr, 15 Sep 2017, Steve wrote:

> Hello,
>
> I have these line in ~/.vim/keymap/touchesfr.vim
>
> loadkeymap
> « «<Char-0xa0>
> » <Char-0xa0>»
> ? <Char-0xa0>?
> ! <Char-0xa0>!
> : <Char-0xa0>:
> ; <Char-0xa0>;
>
> because in French you need a non-breaking space before or after a double
> punctuation. Works great when editing text. But I often want to
> copy-paste an URL and if it contains one of those double punctuation,
> I'll end with <Char-0xa0> in it. So I'll have to manually delete it
> which is rather annoying.
>
> So the question is how could I do to not have this behaviour when
> copy-pasting?

Depends on how you paste. If you paste from the clipboard (and your vim
is compiled with clipboard support) this shouldn't happen. However if
you use something like MiddleMouse Paste with your mouse using X
selection, Vim cannot distinguish this from typing. So you would have to
set `:set paste`.

Best,
Christian
--
Nichts verschafft einem so schnell Achtung, wie wenn man seine
Mitmenschen wissen läßt, daß man ihnen gewachsen ist.
                -- Vita Sackville-West (Erloschenes Feuer)

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Don't load specific keymap when pasting

Steve
Hi Christian,

Le 15-09-2017, à 09:39:26 +0200, Christian Brabandt a écrit :

>> So the question is how could I do to not have this behaviour when
>> copy-pasting?
>
>Depends on how you paste. If you paste from the clipboard (and your vim
>is compiled with clipboard support) this shouldn't happen.

vim --version | grep clip
-clipboard       +job             +path_extra      +user_commands
+eval            +mouse_dec       +statusline      -xterm_clipboard

So it's not.

I paste using Edit-> Paste from the Terminal menu.

> However if you use something like MiddleMouse Paste with your mouse
> using X selection, Vim cannot distinguish this from typing. So you
> would have to set `:set paste`.

Doesn't work with middle mouse button (I used that 15 years ago).

So do you think I should recompile with +clipboard and
+xterm-clipboard? A bit lost here.


Thank you,
Steve

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Don't load specific keymap when pasting

Tony Mechelynck
You can also disable keymaps temprarily while pasting.

Toggling keymaps is Ctrl-^ in Insert mode or ":let &imi = !&imi"
(without the quotes) in Normal mode; and if your keyboard (like my
Belgian AZERTY) doesn't give easy access to Ctrl-^ you can remap it to
something else: I use F8, as follows (this stands before the
"loadkeymap" line in my homemade keymap, but you could also put it in
your vimrc):

" map F8 to toggle keymaps, but only if that key isn't yet used for
" something else
if mapcheck("<F8>", "nvoicsxl") == ""
  map     <F8>    :let &l:imi = !&l:imi<CR>
  sunmap  <F8>
  map!    <F8>    <C-O><F8>
  cmap    <F8>    <C-^>
endif

Best regards,
Tony.

On Fri, Sep 15, 2017 at 10:04 AM, Steve <[hidden email]> wrote:

> Hi Christian,
>
> Le 15-09-2017, à 09:39:26 +0200, Christian Brabandt a écrit :
>
>>> So the question is how could I do to not have this behaviour when
>>> copy-pasting?
>>
>>
>> Depends on how you paste. If you paste from the clipboard (and your vim
>> is compiled with clipboard support) this shouldn't happen.
>
>
> vim --version | grep clip
> -clipboard       +job             +path_extra      +user_commands
> +eval            +mouse_dec       +statusline      -xterm_clipboard
>
> So it's not.
> I paste using Edit-> Paste from the Terminal menu.
>
>> However if you use something like MiddleMouse Paste with your mouse
>> using X selection, Vim cannot distinguish this from typing. So you
>> would have to set `:set paste`.
>
>
> Doesn't work with middle mouse button (I used that 15 years ago).
>
> So do you think I should recompile with +clipboard and
> +xterm-clipboard? A bit lost here.
>
>
> Thank you,
> Steve
>
>
> --
> --
> 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
>
> --- You received this message because you are subscribed to the Google
> Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Don't load specific keymap when pasting

Steve
Hi Tony,

Thank you for your answer. Unfortunately, it's way beyond my understanding.  

I was thinking about something much more automatic, like:

Vim AI: hey, Steve wants to paste something, let's disable temporarily
his keymap, and once pasted, reactivate it.

Something like catching the action of pasting and them triggering the
deactivation of my keymap.

Maybe that's simply not possible with vim. If so, I'll just continue to
delete the inserted non-breakable space. It's not like I paste URLs
every five minutes.

Thanks.

Best regards,
Steve

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.