Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Selecting your pasted text (`gp`)

Open davidnorthetal opened this issue 7 years ago • 2 comments

Hey,

Like in http://vim.wikia.com/wiki/Selecting_your_pasted_text I'm looking for a way to select the text I've just pasted visually in order to indent/format/sed it.

Any help would be appreciated.

davidnorthetal avatar Aug 18 '18 17:08 davidnorthetal

I'd also like to have this. Requires https://github.com/VSCodeVim/Vim/issues/2004 to be implemented. Please upvote that issue to show your support for that feature.

Sirius-A avatar Aug 20 '18 11:08 Sirius-A

Until gp is natively supported I'm using the following (line-wide) emulation (includes a final k since the '] marker seems to wrap to the next line):

{
  "vim.normalModeKeyBindingsNonRecursive": [
    { "before": [ "g", "p" ], "after": [ "V", "'", "]", "k" ] },
  ]
}

mogelbrod avatar Sep 21 '22 16:09 mogelbrod

gp pastes with slightly different behavior than p... Isn't the issue that gv works incorrectly?

J-Fields avatar Sep 22 '22 00:09 J-Fields

If you're referring to my workaround mapping @J-Fields then yes it could be. '] seems be the major culprit since it appears to point to the line after the last when pasting multi-line text.

The simplest repro I could find is:

  1. Create a new file with
    1 0
    2 0
    
  2. Select both lines using Shift+v (visual line mode)
  3. Press y p
  4. Buffer should become
    1 0
    1 0
    2 0
    2 0
    
  5. Press ' ]
  6. Editor should move cursor to line 3, column 3 (the third 0), but instead it moves to line 4, column 1 (the last 2)

mogelbrod avatar Sep 23 '22 07:09 mogelbrod