Monday, May 23, 2016

Re: Use Register as Search Pattern in Ex Mode silent

Am Freitag, 20. Mai 2016 18:46:59 UTC+2 schrieb Ben Fritz:
> On Friday, May 20, 2016 at 3:30:30 AM UTC-5, Marcel Jödicke wrote:
> > Hello Community,
> >
> > I'd like to ask if there is somehow a way to use the Content I saved wit +%y+ before to the Clipboard in EX mode as Search Pattern for the File. I tried it with a ".. combination, but it doesn't work because powershell is complaining for a second " to close the string. I also tried it like \=@@ which works fine as replace pattern, but not for searches. I tried to set it to Register a with @a=@@ And I tried to paste it with <C-r>a , but it doesn't work, because commands like <C-r> are not working in written state. Do you have a solution for that problem. I also would be fine If there is a way to read out the seach pattern from a File somehow with :r.
> >
> > Thank you very much in advance!
> >
> > Marcel
>
> Try using the @0 register like you were trying to use @@, but you'll need to build up your command as a string using :execute to run it, or use the search() function instead of a command if you just need to move the cursor.

Hello Ben,

Thank you very much for your answer!

I looked into :execute, but I'm not really understand the way to use it. For example, I have now found a way to do that with let. I open my 3 files in seperate tabs with the -p parameter, copy my replacement pattern with let @@=getline('.'), copy my search pattern with @/=getline('.') and search and replace in the main File with :%s//\=@@/g how would I make such command with exec? Sadly the let command doesn't seem to work silent, else my problem would be solved...

Thanks again
Marcel

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: