Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > recoding files from Mac to Unix (not a line break problem)

recoding files from Mac to Unix (not a line break problem)
Thread Tools
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
Jan 20, 2003, 06:32 AM
 
When I want to edit converted .tex files (written in TeXShop) in vim or in vi, instead of being able to move line-by-line, my cursor jumps from paragraph to paragraph.

The .tex files have to be converted to a Unix-friendly format so that they can be read and edited by a co-worker of mine that uses a Linux box.

Any suggestions?
I don't suffer from insanity, I enjoy every minute of it.
     
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Jan 20, 2003, 12:09 PM
 
Actually, this is a line break problem - you don't have enough of them.

Each time you move a line in vi, it moves to the next LINE (as denoted by the LF character) which may be more than one visible line of text in your terminal.

I don't know enough about .tex files to know if you can arbitrarily insert line feeds where you want.

The alternative is to use the oft-overlooked option-click in the terminal. This calculates the correct sequence of keystrokes to tell vi where to position the cursor. I know this kind of defeats half the purpose of a command-line utility, but it might solve your problem.
Gods don't kill people - people with Gods kill people.
     
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
Jan 20, 2003, 06:06 PM
 
A third alternative is to use the commands "gj" and "gk" in vim (instead of "j" and "k"). The g'd versions jump a virtual (ie screen) line instead of a real LF delimited line. Boo to arrow keys!!!

Cheers,
Paul
     
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
Jan 21, 2003, 06:07 AM
 
The problem is that the co-worker has a Linux box and doesn't want to adjust one bit.

I am supposed to mouth-feed him with files that he can process.

Is there a way to convert my .tex files? If so, how? Or can I set an option in vim to ?soft wrap' my files (ok, this is terminology that I know from Mailsmith)?

The only thing that I can make him do is install vim (he still works with vi), but nothing more.

Any help would be appreciated. (As I am getting paid for this.)
I don't suffer from insanity, I enjoy every minute of it.
     
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Jan 21, 2003, 09:11 AM
 
Why don't you just tell him to edit the file in a word processor instead of in his terminal?

Chris
     
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
Jan 21, 2003, 04:34 PM
 
He's about 45-50, worked all life long on all kinds of computers. He grew up on vi. Seriously, this is a no go.
I don't suffer from insanity, I enjoy every minute of it.
     
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Jan 21, 2003, 05:08 PM
 
If he's worked all his life on all kinds of computers, he ought to be able to use more than vi. However, since you're getting paid to solve his problem...

Chris
     
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
Jan 21, 2003, 05:37 PM
 
Here's an off the cuff attempt to do something moderately sensible: it takes your input file and reformats any line that's longer than 80 columns (change as necessary) so that it wraps. That is, shorter lines will be untouched (as you probably want, rewrapping those carte blanche would produce a horrible mess). With any luck this will produce something easier to work with in vi.

% perl -pi -MText::Wrap -e '$columns=80;$_=wrap("","",$_) if length($_)>80' longlines.tex

Make a backup of your test file first (or if you want to have a backup made automatically just use

% perl -pi -MText::Wrap -e.bak '$columns=80;$_=wrap("","",$_) if length($_)>80' longlines.tex

and you'll have your original file in longlines.tex.bak)

Best of luck,
Paul
     
Moderator
Join Date: May 2001
Location: Hilbert space
Status: Offline
Reply With Quote
Jan 22, 2003, 03:08 AM
 
That is probably exactly what I am gonna do. Thanx a lot.
I don't suffer from insanity, I enjoy every minute of it.
     
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status: Offline
Reply With Quote
Jan 23, 2003, 09:12 AM
 
Similar to what Paul said, I use the "gq" command in vim. The way I do it is as follows:

Go to beginning of the section I want to reformat.

Type "ma". This says to mark the current line as mark "a".

Go to the end of the section I want to reformat.

Type "gq'a". This says reformat everything between the current position and mark "a".
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:32 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2