Tuesday, January 14, 2014

Re: Copying and pasting text to Vim

On 14.01.14 07:12, shawn wilson wrote:
> On Tue, Jan 14, 2014 at 3:11 AM, Erik Christiansen
> > OK, I tend to leave autoindent on, and so have to set "paste" in Vim
> > beforehand, to avoid staircase text while pasting, and then set nopaste
> > afterwards. To minimise keystrokes, I have in .vimrc:
> >
> > set pastetoggle=<F12>
>
> Though, if you use the native xclipboard (and have the feature - I
> think it's called 'clipboard') then you can just do "+p and not have
> to worry about toggling anything or 'staircase' issues.

Ah, that's very nifty. Thanks.
I've mapped it to ^P, which wasn't doing anything useful.

nnoremap ^P "+p
inoremap ^P ^["+p^Mi

The latter handles the case where we happen to be in insert mode, and
also allows an i or o to put the paste on a new line, rather than
grafting it onto the one the cursor is on.

One peculiarity I notice is that "+p picks up clipboard contents
provided by cursor highlighting in another window - up until the
clipboard is filled by Vim, e.g. with "+y}. After that, new cursor
highlighting operations fail to change the contents of "+p, which
remains stuck on the old contents, even after half a dozen attempts.
(Perhaps I need to move to a later Vim. I'm on 7.3 with patches 1-496)

Erik

--
For the month of December 2013, 57.4% of all the electricity consumed in Denmark
was generated by wind turbines. Over the whole year, it was 33.8%, and on 21st
December, the wind turbines produced over 100% of Denmark's electricity consumption.
- http://epn.dk/brancher/energi/alternativ/ECE6403277/danske-vindmoeller-skriver-verdenshistorie/

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment