Computing.Net > Forums > Unix > Repeat previous subsitution command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Repeat previous subsitution command

Reply to Message Icon

Name: deeps
Date: September 14, 2005 at 04:31:15 Pacific
OS: Linux
CPU/Ram: 3GB
Comment:

Can someone tell me how do i retrieve the previous replacement command i type in vi.

For example:
while editing a file in vi, i type
:%s/star/stark/g

Now i realise that it should be starch instead of stark, so i did like to retrieve the old typed command just like retrieving the command from history in shell.

This thing is particularly helpful while writing lenghthy subsitution statments and for a single mistake you dont have to retype the whole command.

Any help would be welcome.



Sponsored Link
Ads by Google

Response Number 1
Name: Luke Chi
Date: September 14, 2005 at 07:51:36 Pacific
Reply:

I don't think there's a way to do it.

I deal with it by using 3 monitors attached to one PC (then, I have more screen space to use) and open a notepad to use it as a job recorder.

For example:

In order to do the job you described above I type:
%s/star/starch/g
in the notepad and copy/paste it to vi

If I need to modify it, I modify it in the notepad and copy/paste it to vi:

...
%s/star/stach/g
%s/star/stark/g

After the job is done I save this notepad as an archive file for future reference.

Luke Chi


0
Reply to Message Icon

Related Posts

See More


Awk to parse and output sort data



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Repeat previous subsitution command

'find' syntax www.computing.net/answers/unix/find-syntax/4623.html

sqlplus from unix shell www.computing.net/answers/unix/sqlplus-from-unix-shell/8207.html

String manipulation www.computing.net/answers/unix/string-manipulation/7391.html