Change first space in each paragraph to a tab

B

Brian Holfield

Does anyone have a simple macro that will change the first space in
each paragraph to a tab? Greatly appreciate some help with this.
 
B

Brian Holfield

Thanks, Jezebel, but this will only work if the first character of each
paragraph is a space. I have no way of knowing how many characters
occur before the first space in each paragraph.
Find and Replace will do this. Search for ^p[space], replace with ^p^t.





Brian Holfield said:
Does anyone have a simple macro that will change the first space in
each paragraph to a tab? Greatly appreciate some help with this.
 
J

Jezebel

Sorry, I assumed you meant leading space. For the cases where there are
intervening characters, check the 'Use wildcards' checkbox and use

Search for: (^013[! ]{1,})[space]
Replace with: \1^009



Brian Holfield said:
Thanks, Jezebel, but this will only work if the first character of each
paragraph is a space. I have no way of knowing how many characters
occur before the first space in each paragraph.
Find and Replace will do this. Search for ^p[space], replace with ^p^t.





Brian Holfield said:
Does anyone have a simple macro that will change the first space in
each paragraph to a tab? Greatly appreciate some help with this.
 
B

Brian Holfield

Thanks, Jezebel, but I'm still having trouble, probably because I
have little undertanding of the symbols used. With 'Use wildcards'
checked and ignoring the asterisks, I've tried these combinations for
find, but none of them works:
*(^013[! ]{1,})[space]*
*(^013[! ]{1,})[ ]*
*(^013[! ]{1,}) *
 
J

Jezebel

[space] just means a single space, no brackets, so your third option looks
right. What it all means:

^013 is a paragraph mark
[! ] means "not space"
{1,} means one or more of the preceding matching -- in this case [! ]{1,}
means one or more non-spaces
Tbe brackets are for grouping, to match up with the \1 in the replace
string.

So all combined, what you're searching for is "paragraph mark followed by
one or more non-spaces followed by a space". You're replacing with "whatever
was matched by the contents of the brackets, plus a tab"

I tested it -- it does work.
 
B

Brian Holfield

Thanks again , Jezebel. Slowly getting there. Seems like I have a
problem within a problem. I believe the reason nothing was happening
was because I was using the Czech version of Word. Let's leave that
aside for a moment.

When I use the American version of Word, the Find works, but not as I
want it to. The wild card expression selects a paragraph mark and the
text in the next line up to and including the first space. I'm trying
to find the first space in each line. Example:
abc def ghi
a bcd fgh i
ab cdfg hi
line 1, needs selection of the space between c and d
line 2, needs selection of the space between a and b
line 3, needs selection of the space between b and c

I tried reading the help on wild cards, but it was beyond me. Really
needs an expert.
 
G

Greg

The method Jezebel provide will work for all paragraphs except
paragraph 1. That one you will need to do manually. If it isn't
working, then the units that you are called paragraphs (i.e., lines)
are not in fact individual paragraphs.
 
J

Jezebel

Yes, it finds the paragraph mark. That's OK: it's just another character,
and it gets replaced.
 
J

Jean-Guy Marcil

Brian Holfield was telling us:
Brian Holfield nous racontait que :
Thanks again , Jezebel. Slowly getting there. Seems like I have a
problem within a problem. I believe the reason nothing was happening
was because I was using the Czech version of Word. Let's leave that
aside for a moment.

Replace the "," by a ";"
The semi-colon is probably the list delimiter in Czech, as it is in many
European version of Windows.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
B

Brian Holfield

Oops! Yes, It works. I shot myself in the foot by not understanding the
code and going step by step. When I saw so much selected by the find my
reaction was: Whoa, I don't want to replace all that with a tab. But,
now I see that the replace code takes care of that nicely. Thanks for
being so patient with me, Jezebel, and thanks for solving a problem
that was holding me up.
 
B

Brian Holfield

Yes, it works nicely, Greg. My paragraphs were OK, it was my mental
attitude that tripped me up - see reply to Jezebel
 
B

Brian Holfield

Thanks for the suggestion, Jean-Guy. That's probably the right
direction, but it needs something in addition to changing , to ;.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top