Saturday, November 19, 2011

Re: autocommand to replace special characters into a file.

Hello All,
Hello Ben and Tony,
 
Here I'm reposting my message.
 
indeed Tony helped me a lot there was a missing % to substitute all occurences of the searched string into the edited file.
 
This is what I will have in my command:
  
au VimEnter,BufNewFile,BufRead,BufEnter  *.log  %s/^M\|^A/ |
 
Now the question is :
1 - how to I type ^A special ?  I know how to type ^M with <CTRL-V> but not  ^A
2 - in case there's no ^M or ^A to be replaced in my *.log file, how to make it silent ?
 
 
Hope my questions are clear.
 
Thank you again for your help and attention.
 
Eddine.
 
 


 
2011/11/14 Eddine <bmokadem@googlemail.com>
Hello
 
 
 
 
At work I have to edit regurlarly files containing special characters like ^M or ^A
 
for the moment Im' at the first stage where I just try to make replace a string by another one in my autocommand:
 
 
au VimEnter,BufNewFile,BufRead,BufEnter  *.log  s/string1/string2/
 
 
 
But this doesn't give me good results:
Wehn opeining a .log file, Vim prompts me to know if I want to replace the first occurence ;
hitting "y" (yes key) change the first matching one then brings me error messages :
 
E488: trailing characters
E486: pattern not found string1
 
Any mean to make it replace all matching strings whitout prompting and without error ?
 
Thanks in adavance for your help.
 
Eddine.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: