>Because... since the line endings are messed up I only have 1 line.
>One very long line.
In that case, you're in trouble because "real" vi only allows you
a certain maximum line length. So if you do this a lot, eventually
your file will get truncated.
If you're not using "real" vi and you're using vim instead, you probaby
want to check into the support that vim has for automatically
recognizing line endings and "doing the right thing"[1].
Quote:>I chose _ because I thought it was undefined. Where can I find a list of
>unused keys?
Good question. vi documentation isn't the greatest. I've been using
it for over 10 years, and I'm still finding about new things through
word of mouth. :-)
Your first task is to figure out what version of vi you're using. From
there you might take a look at http://www.thomer.com/thomer/vi/vi.html
and http://www.vi-editor.org/ .
Quote:>You make it sound like a cmd can be mapped to a multi key combo [? -- is
>that true?
Yes. For example, in my ~/.exrc, I have the following:
map [f {!}fmt^M
(It's a real control-M in my .exrc file.) This allows me to just hit
"[f" in the middle of any paragraph of text (after hitting escape, of
course), and then vi will send it to "fmt" for formatting. I also
have
map [d :r!date^M
to read the date into the current buffer. I like to use letters with
"[" because that makes the bindings a little less arbitrary.
Quote:>Unfortunately I can't extend the pattern to accomplish my real goal which is
>to map "s/<ctl-M>/<ctl-rtn>/g" to a key. If I enter that sequence in by hand
>it replaces all the ^M in the file with hard carriage returns for a
>particular file.
Well, as I mentioned earlier, this approach is unlikely to be useful,
so I'd just use Perl like someone else suggested.
- Logan
[1] As long as your opinion of "the right thing" is to let you edit
the file and continue to use its line-end convention, instead of
converting it to the native line-end convention.
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos