1

I'm learning my way around the vim and got around to copy-paste. Or yank-paste. Now when I try to paste a yanked piece of text, it pushes previous content to the right and squeezes in on the left. I took 2 screenshots to show you what behaviour I mean. And

before pasting: before paste

after pasting: after pasting

I don't think that my .vimrc affects pasting behaviour:

execute pathogen#infect()
set number
set tabstop=3 "tabs are 3 spaces big (smaller than default)
set shiftwidth=3 "3 spaces are also used with auto indent
set smartindent "You'll keep the indentation on the next line when you press enter.

"auto complete brackets
inoremap { {}<Esc>i 
inoremap [ []<Esc>i
inoremap ( ()<Esc>i

let g:solarized_termcolors=256
syntax on
set t_Co=256
colorscheme solarized
set background=light

"remap CTRL-c in visual mode for copy to clipboard
vnoremap <C-c> "+y

"Let vim change the working directory automatically (so you can open files from the current path)
set autochdir

"Open new split panes to right and bottom, which feels more natural than Vim’s default:
set splitbelow
set splitright

"map a key to maximize current screen
map <F5> <C-W>_<C-W><Bar>
map <F6> <C-W>=
  • Do you use Visual Block (Ctrl-v) to make the selection you want to copy? If so, it's a normal behaviour, try Visual Lines (Shift-v) to make your selection. – apaul May 27 '15 at 14:37
0

In vim there's various ways to copy/paste. (In the enumeration below I'm just showing the three variants using first marking the text then copy/pasting.)

  1. Select a range of whole lines: type V, move to end of range, type y. Then go to the target position and use p to print the text below the current line or use P to print it above.
  2. Select a range of text with accuracy of characters: type v, move to the end of the area (which may be on another line), type y. Then go to the target position and use p to print the copied text after the current charater or P to print it before. (Existing line breaks are preserved.)
  3. Select a block of text: type Ctrl-V, move to the end of the rectangular block, type y. If this block is pasted inside existing text then that existing text will be shifted to the right to make place for the new text.

Your copy/paste method seems to have been 3. - Use one of the other methods that fits your needs best.

  • Thank you Janis, this was so helpful. Indeed I used the visual block method :) – sjbuysse May 27 '15 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.