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 09-26-2007, 12:22 PM   #1
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Rep: Reputation: 16
Question vi vagaries


I just discovered something unexpected in vi (vim actually). Here's the situation:
Inside a single bash shell (RH Enterprise 4), I found that you can open a vi session on a file, use yy to yank some lines, close the vi session, vi a different file, and paste the yanked lines into it.
The surprise came when I discovered that regardless of how many lines you yank, only the first 50 lines can be pasted into the second file. It's great to be able to yank & paste between files, but why would you want to cap the number of lines at 50?
And now for a more practical question; is the 50 line limit hard coded into a binary somewhere? Can you set the number higher and if so, where?

WN
 
Old 09-26-2007, 12:29 PM   #2
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Original Poster
Rep: Reputation: 16
Oh, I forgot to include another detail:
If you vi both files with the same command, then the 50 line limit doesn't come into effect and you can paste as many lines into the second file as you want.
Code:
 vim file1 file2
 
Old 09-26-2007, 01:08 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
50 lines may be a hard-coded default, but vim should allow you to override that default.

yy will yank the current line; 55yy should yank the current line plus the next 54 lines.
 
Old 09-26-2007, 01:38 PM   #4
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
I looked at source and even though I didn't get into the details my impression is that 50 is hardcoded magic number. When you do "yy" lines are copied into the buffer named `"'(in some places of Vim help they also called "registers"). When you close vim session the current state is stored in ~/.viminfo, and it looks like that only 50 lines are copied from the RAM. You could examine this file for you educational pleasure. The relevant source which does the job is in .../vim71/ops.c and option.c . I didn't see the way to overwrite the default.

Last edited by rsashok; 09-26-2007 at 01:41 PM.
 
Old 09-26-2007, 02:58 PM   #5
WingnutOne
Member
 
Registered: Sep 2007
Location: Kansas City
Distribution: Mixed, mostly RH / Fedora
Posts: 76

Original Poster
Rep: Reputation: 16
Thumbs up

Thanks for the replies!
Since I could work around it already, "educational pleasure" was pretty much the only reason I asked anyway. Isn't it amazing the strange (and often useless) things that geeks like me can get curious about?
 
Old 09-26-2007, 03:09 PM   #6
rsashok
Member
 
Registered: Nov 2006
Location: USA, CA
Distribution: RedHat, Debian
Posts: 202

Rep: Reputation: 31
If there is something we could know about there is no reason we should not.
 
  


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



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

All times are GMT -5. The time now is 04:42 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
Open Source Consulting | Domain Registration