• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

simple vi question

Beattie

Golden Member
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?
 
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.
 
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.
 
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
 
Back
Top