simple vi question

Beattie

Golden Member
Sep 6, 2001
1,774
0
0
I have a file with a bunch of lines like

word "|some crap is here"

and I want to make it like

word word@something.com

if I do something like -- :s/"|.*/something.com/ -- it's close but I need a way to also (ye) yank and (p) paste the "word" part in within the replace. I guess the yank has to happen outside of the search though... How can I do this?
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
sed would probably be better for this. Personally, I would use Ruby though, but that is because it's easy and I know it well.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I'm not sure of the syntax for vim, but in perl regexes you can wrap a match in parenthesis and then reuse whatever the match was in the replacement. Sort of like 's/(^\w+).*/$1 $1@something\.com/g'. Or something like that anyway, it's been a while.
 

Skeeedunt

Platinum Member
Oct 7, 2005
2,777
3
76
Originally posted by: Beattie
I just did it in emacs. macros ftw.

Sounds similar to recording in Vim.

qq to start recording keystrokes to register q
/word<enter>lc$word@something.com<esc>
q to stop recording
@q to replay q
@@ to replay last