Re: Replacing '%' in a text file

2006-10-10 Thread Muhammad Farooq-i-Azam


--- Tim Chase [EMAIL PROTECTED] wrote:

  I have to replace every occurrence of % in a file
 with
  % |. I have been effectively replacing text using
 the
  following construct:
  
  :%s/\text\/replacement/g
  
  However when I try to do the following:
  
  :%s/\%\/% |/g 
  
  I am greeted by an error message. Obviously, the %
  character needs to be treated differently for
 being
  replaced. Escap sequence? 
 
 The error message returned should give a clue
 regarding the 
 problem (E486: Pattern not found: \%\).  Your
 pattern 
 \text\ works well for words, ensuring that you
 don't find 
 them as a sub-portion of some other word (such as
 finding the 
 foo in food, snafoo, or confoosion). 
 However, the \ 
 and \ tokens require a transition from a
 non-word-character to 
 a word-character (or vice-versa).  The %
 character, by default, 
 is not a key-word character (though this can be
 altered by 
 changing the 'iskeyword' setting).
 
 Unless there is some context in which you *don't*
 want to replace 
 a % with % |, you can just use
 
   :%s/%/% |/g
 
 without the \ and \ markers.  You can read
 more about the 
 problematic operators at
 
   :help /\
 
 or making them part of the set of characters that
 constitute a 
 keyword, by reading at
 
   :help 'iskeyword'
 
 HTH,
 
 -tim
 

Thanks. The problem is now resolved.

--
Muhammad Farooq-i-Azam

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Replacing '%' in a text file

2006-10-09 Thread Muhammad Farooq-i-Azam
I have to replace every occurrence of % in a file with
% |. I have been effectively replacing text using the
following construct:

:%s/\text\/replacement/g

However when I try to do the following:

:%s/\%\/% |/g 

I am greeted by an error message. Obviously, the %
character needs to be treated differently for being
replaced. Escap sequence? I cannot figure out how to
do it. May be trivial for the gurus here. I will be 
thankful for a hint.

Many thanks in advance.

--
Muhammad Farooq-i-Azam 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com