VIM

2001-11-05 Thread Craigsc
H




Re: VIM

2001-09-19 Thread mose

On Wed, Sep 19, 2001 at 01:40:17PM +1000, Craig Sanders wrote:
> On Tue, Sep 18, 2001 at 06:53:00AM -0400, Jesse Goerz wrote:
> > On Tuesday 18 September 2001 04:38, Craig wrote:
> > > Need to do an extended find and replace with VIM, anyone
> > > know the syntax for me ? I have a really long named.conf
> > > file I need to modify ...
> > 
> > sed -e 's/what_to_find/replace_it_with_this/g' named.conf
> > 
> > By default it sends all the output to stdout.  You can redirect 
> > it to another file.  It does multi-line as well.  Try info sed 
> > or Google it.  Very cool program.
> 
> try this instead:
> 
> perl -p -i -e 's/find/replace/g' file1 file2 file3 ... fileN
> 
> no need to mess around with temporary files, or stdout - perl edits
> the file(s) in-place with the -i argument.
> 
> it can optionally make a backup copy of the file(s) before editing them.
> use e.g. "-i.bak" for that.
> 

- just for information there is also a small tool that is very useful
in that case, named replace, being a part of msql2mysql but widely
usable.

(it's included in mysql-server debian package)

hth
mose

--
< mose >   < Makina Corpus >   < 105, avenue Parmentier > 
< http://makina-corpus.com >   < FR 75011 PARIS >
< P: +33 (0) 1 53 36 18 59 > < F: +33 (0) 1 40 21 03 39 >


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: VIM

2001-09-18 Thread Craig Sanders

On Tue, Sep 18, 2001 at 06:53:00AM -0400, Jesse Goerz wrote:
> On Tuesday 18 September 2001 04:38, Craig wrote:
> > Need to do an extended find and replace with VIM, anyone
> > know the syntax for me ? I have a really long named.conf
> > file I need to modify ...
> 
> sed -e 's/what_to_find/replace_it_with_this/g' named.conf
> 
> By default it sends all the output to stdout.  You can redirect 
> it to another file.  It does multi-line as well.  Try info sed 
> or Google it.  Very cool program.

try this instead:

perl -p -i -e 's/find/replace/g' file1 file2 file3 ... fileN

no need to mess around with temporary files, or stdout - perl edits
the file(s) in-place with the -i argument.

it can optionally make a backup copy of the file(s) before editing them.
use e.g. "-i.bak" for that.

craig

-- 
craig sanders <[EMAIL PROTECTED]>

Fabricati Diem, PVNC.
 -- motto of the Ankh-Morpork City Watch


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: VIM

2001-09-18 Thread Jesse Goerz

On Tuesday 18 September 2001 04:38, Craig wrote:
> Hi ladies and fellas
>
> Need to do an extended find and replace with VIM, anyone
> know the syntax for me ? I have a really long named.conf
> file I need to modify ...
>
> Kind regards
> Craig

sed -e 's/what_to_find/replace_it_with_this/g' named.conf

By default it sends all the output to stdout.  You can redirect 
it to another file.  It does multi-line as well.  Try info sed 
or Google it.  Very cool program.

Jesse 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: VIM

2001-09-18 Thread Hugues Obolonsky

Charl Matthee wrote:
> 
> On Tue Sep 18 2001 at 10:38:57AM +0200 'Craig' <[EMAIL PROTECTED]> wrote:
> 
> > Need to do an extended find and replace with VIM, anyone
> > know the syntax for me ? I have a really long named.conf
> > file I need to modify ...
> 
> :%s/thing_to_find/thing_to_replace/gc
> 
> g: global
> c: check with operator before substituting
> 
> If you need to find and replace over multiple lines I suggest you rather
> use a little perl script.

maybe if you want to script, you can use the -s option of vim

cat < EOF > cmd.file
:1,$s/thing_to_find/thing_to_replace/
:wq
EOF

vim -s cmd.file named.conf

regards
hugh

> 
> Ciao
> 
> Charl
> __
> 
>Making reality real since 1974.
> __
> 
>   [ Charl Matthee ] [ +27-11-721-3800 ]
>   [ Reality Manufacturing ] [ +27-11-405-6508 ]
> __
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: VIM

2001-09-18 Thread Charl Matthee

On Tue Sep 18 2001 at 10:38:57AM +0200 'Craig' <[EMAIL PROTECTED]> wrote:

> Need to do an extended find and replace with VIM, anyone
> know the syntax for me ? I have a really long named.conf
> file I need to modify ...

:%s/thing_to_find/thing_to_replace/gc

g: global
c: check with operator before substituting

If you need to find and replace over multiple lines I suggest you rather
use a little perl script.


Ciao

Charl
__

   Making reality real since 1974.
__

  [ Charl Matthee ] [ +27-11-721-3800 ]
  [ Reality Manufacturing ] [ +27-11-405-6508 ]
__


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




VIM

2001-09-18 Thread Craig

Hi ladies and fellas

Need to do an extended find and replace with VIM, anyone
know the syntax for me ? I have a really long named.conf
file I need to modify ...

Kind regards
Craig


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]