[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how do i create keyboard shortcut to specific query-replace?

From: Dan Espen
Subject: Re: how do i create keyboard shortcut to specific query-replace?
Date: Mon, 30 Sep 2013 20:48:24 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Hod b <address@hidden> writes:

> Hello
> I've trying to create a keyboard shortcut that replace some query that i
> have in many(!) files with similar query.
> Example:
> original code: 
> foo( type => 'bar', action => 'execute bar' );
> foo( type => 'baz', action => 'special action' );
> foo( type => 'bat', action => 'yyyyy' );
> foo( type => 'bar', action => 'bar finished' );
> new code: 
> bar( action => 'execute bar' );
> baz( action => 'special action' );
> bat( action => 'yyyyy' );
> bar( action => 'bar finished' );
> I don't want to do that automatically to all my files,
> because it depend on projects that we are work at the company.
> my regex to this problem is s/foo\(\s+type\s+=>\s+'(\w+)',\s+/$1( /g
> but i don't know how to save it to .emacs
> thanks for trying help me.

With emacs, I've never found the need to write such complicated

It's simpler to record a keyboard macro, name it, save it and
assign a key to it.

For the change you make above:

 foo( type => 'bar', action => 'execute bar' );
 bar( action => 'execute bar' );

move to before foo, start recording.
zap to ', forward word, type (,
zap to a, type space, a, move down a line
go to beginning of line, end recording.
Then name the macro, save it,
assign key.

Dan Espen

reply via email to

[Prev in Thread] Current Thread [Next in Thread]