<font size="4">In vim what you sent translates to my needs as listed below and works like a charm! Thanks for the information!<br><br>:6,14 s/^\(.\{84\}\)1\(.*\)$/\10\2/<br><br clear="all"></font><font size="4">Best wishes,<br>
Dow<br>________________________________________________<br>Dow Hurst, Research Scientist<br>340 Sullivan Science Bldg., Dept. of Chem. and Biochem.<br>University of North Carolina at Greensboro<br>PO Box 26170 Greensboro, NC 27402-6170</font><br>
<br><br>
<br><br><div class="gmail_quote">On Thu, Mar 10, 2011 at 7:28 AM, Byron Jeff <span dir="ltr"><<a href="mailto:byronjeff@mail.clayton.edu">byronjeff@mail.clayton.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Thu, Mar 10, 2011 at 02:04:15AM -0500, Dow Hurst wrote:<br>
<br>
> I'd like to construct a vim based search and replace statement. I want<br>
> to search between a set of line numbers for the 85th character on a line<br>
> and if it contains a "1" then turn it into a "0". I just don't know how<br>
> to set up that particular search pattern and replace pattern.<br>
<br>
</div>The following should work in vim. Not sure about raw vi:<br>
<br>
:%s/^\(.\{84\}\)1\(.*\)$/\10\2/<br>
<br>
Here is an expanded version with some backslashes eliminated for explanation:<br>
<br>
:%s/^ ( .{84} ) 1 ( .* ) $ / \1 0 \2 /<br>
<br>
The :%s/^ is the standard substitute all lines and mark the beginning of the line.<br>
<br>
The parens in the expression are grouping operators. Needs backslashes to<br>
mark as special operators. Each group captures and saves the match so that<br>
it can be reinserted in the substitution. The groups are numbered starting<br>
with 1.<br>
<br>
So the first group captures .{84} which matches exactly 84 charaters.<br>
<br>
The 1 matches the 1 in the 85th column.<br>
<br>
The .* is the second group which captures the rest of the line after the<br>
85th character. Probably could get away without it (*). The $ is the end of the<br>
line.<br>
<br>
Once a line is matched then the substitution is pretty simple:<br>
<br>
The \1 is the first group which is the first 84 characters.<br>
the 0 substitutes for the 1.<br>
the \2 is the group for the rest of the line.<br>
<br>
(*) This should also work:<br>
<br>
:%s/^\(.\{84\}\)1/\10/<br>
<br>
Good Luck.<br>
<br>
BAJ<br>
<div class="im"><br>
><br>
> It's been a long time since I've posted to the list. It is nice to see the ALE group is flourishing. I miss going to the meetings...<br>
><br>
> Best wishes,<br>
> Dow<br>
> ________________________________________________<br>
> Dow Hurst, Research Scientist<br>
> 340 Sullivan Science Bldg., Dept. of Chem. and Biochem.<br>
> University of North Carolina at Greensboro<br>
> PO Box 26170 Greensboro, NC 27402-6170<br>
><br>
><br>
<br>
</div>Content-Description: ATT00001..txt<br>
> _______________________________________________<br>
> Ale mailing list<br>
> <a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
> <a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
> See JOBS, ANNOUNCE and SCHOOLS lists at<br>
> <a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br>
<br>
--<br>
Byron A. Jeff<br>
Department Chair: IT/CS/CNET<br>
College of Information and Mathematical Sciences<br>
Clayton State University<br>
<a href="http://cims.clayton.edu/bjeff" target="_blank">http://cims.clayton.edu/bjeff</a><br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</blockquote></div><br>