LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-13-2010, 06:50 AM   #1
chekhov_neo
LQ Newbie
 
Registered: May 2010
Location: Bangalore
Distribution: Ubuntu
Posts: 22

Rep: Reputation: 2
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!
 
Old 07-13-2010, 07:29 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
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
  backup              incsearch           showcmd
  helplang=en         modified            showmatch
  history=50          mouse=a             ttyfast
  backspace=indent,eol,start
  backupskip=/tmp/*,/var/spool/cron/*
(So are vi settings).

The only thing I have "different" is a .exrc file (that sets things for vi)
Code:
cat .exrc
set autoindent showmode showmatch
Maybe comment everything in your .vimrc then un-comment one-by-one?

Hope this helps some.
 
Old 07-13-2010, 07:52 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
Just to confirm ... the file was not created in Windows? Sometimes the funky characters at the end make weird stuff happen.
 
Old 07-13-2010, 08:08 AM   #4
chekhov_neo
LQ Newbie
 
Registered: May 2010
Location: Bangalore
Distribution: Ubuntu
Posts: 22

Original Poster
Rep: Reputation: 2
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.
 
Old 07-13-2010, 10:34 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
'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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy/paste a line in nano editor smp0219 Linux - Newbie 7 01-03-2016 07:40 PM
copy paste fro wondows to vi editor golestani Linux - General 3 02-03-2010 01:18 AM
Inquiry:How to Copy/Paste in vi text editor ? hadimotamedi Linux - Newbie 7 09-19-2009 06:28 AM
Inquiry:How to copy/paste in vi text editor hadimotamedi Linux - Newbie 7 08-31-2009 07:58 PM
CLI editor scripting paste sidlover Programming 3 11-14-2008 05:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration