3

New to linux :-)

In my .bashrc I have set -o vi.
That way when I'm in the terminal I can press CTRL +{ and then use VI commands to navigate, edit and search the command history.

One thing I cannot figure out is how to find and replace. Let's say for example, I have the following command cp /abc/*.src /def/*.src. How can I find/replace src with trg?

To clarify, I'm NOT in the VI/VIM editor. I'm on the command-line. For example, on the command-line to access the last command, i can do the following:

CTRL +{ k

Then to append to the end of command I can do:

$ a

How can I change my command using find/replace on the command-line.

Thanks

3
  • So what for all discussion about vi (in title, tags, ...) as time as you want find/replace on the history command-line? Jul 25, 2013 at 18:08
  • @hba I'm just wondering if you got the answer or not. BTW, it would be better if you highlight 'Bash in vi mode' in your question title :)
    – Drake Guan
    Dec 21, 2014 at 15:11
  • @Drake - done...no I still don't know how to do this...
    – hba
    Dec 22, 2014 at 8:14

1 Answer 1

1

The command for replacing a string with another in vi editor is

  %s/FindMe/ReplaceME/g

for more information on usage : vim

0

Not the answer you're looking for? Browse other questions tagged .