 |
 |
recoding files from Mac to Unix (not a line break problem)
|
 |
|
 |
|
Moderator 
Join Date: May 2001
Location: Hilbert space
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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".
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|