tags:

views:

106

answers:

3

Hi,

I am a bit of a beginner when it comes to Vim and it is currently irritating me in many ways. One of which is the following:

Say i have the following text in a file

one  
two  
three  
four  

dog  
frog  
log  
mog  

and I have used visual mode to select the number words (4 lines) if I then use P to paste at the 'd' in dog i get the following:

one
two
three
four


one  dog
two  frog
threelog
four mog

My desired output would be:

one
two
three
four


one
two
three
four
dog  
frog 
log
mog

I've noticed that it behaves as I expect if i do a y4y instead of visually selecting the lines. So what is causing the difference in behavior that I am seeing? and how can I get my visually selected block to paste as I would like?

+7  A: 

Seems that you are entering into the Visual Block selection mode (Ctrl-V).

To get your desired output, enter into a Linewise Selection mode, just by pressing V.

CMS
See also: [Visual Modes](http://en.wikibooks.org/wiki/Learning_the_vi_editor/Vim/Modes#visual)
CMS
Thanks for the explanation I new it was something simple :)
radman
A: 

try

:set paste

before pasting.

Aif
Your answer works for most of the vim-paste related questions, but not this one. On a more serious note, use Aif's answer if you find vim being more smart and indenting your pasted text.
jeffjose
+1  A: 

Use Shift+V, it selects line by line

Nicolas Viennot