vi editor - yank and paste problem
Hi,
I have a peculiar problem in vi editor. When I yank('y') a text and paste('P'), the text which is below gets shifted right instead of shifting down. e.g. in the following text: Line 1 Line 2 Line 3 Line 4 Line 5 if I yank the first two lines and paste it before "Line 3", I'm getting the following output: Line 1 Line 2 Line 1Line 3 Line 2Line 4 Line 5 when I want it to be like this: Line 1 Line 2 Line 1 Line 2 Line 3 Line 4 Line 5 My vimrc file has the following contents: syntax on set paste colorscheme darkblue set tabstop=4 set noai set shiftwidth=4 set smarttab set expandtab set softtabstop=4 --------------- Please help! |
Trying the above with vi (not vim), everything works as expected; i.e., get on the first line, type 2yy, get to line 4, type p, viola. Do similar things and use upper case P (to paste above) and lower case p (to paste below) and all is well.
Hmm. Did the same thing in vim, same results. Hmm. So vim settings are Code:
autoindent hlsearch ruler ttymouse=xterm2 The only thing I have "different" is a .exrc file (that sets things for vi) Code:
cat .exrc Hope this helps some. |
Just to confirm ... the file was not created in Windows? Sometimes the funky characters at the end make weird stuff happen.
|
Hi,
I guess I figured out the problem. I use visual mode to yank the text. So what I did was 1. Press Ctrl+V to go to visual mode 2. Press 'y' to yank the text. 3. Press 'p' to paste the text. In the above case, the text which were present already were shifting right. But when I used 'yy' in step2 the text shifted below! So 'y' and 'yy' seem to have different usages. |
'y' is to yank what you wanted, ie yw - will yank a word
'yy' is to yank an entire line, ie yank yank is from start to end of single line |
All times are GMT -5. The time now is 06:38 PM. |