Monday, May 5, 2014

Re: S&R with search input from a file

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBCgAGBQJTZ7eIAAoJEERGtGilKM7wm/4H/10BUn72XUGRqh2FjArwtI/4
pzqzrx6sylOP3DpREepXo7UgHBbssihoQNNsbawRyDpwGP2dsyjK8itFmjDn5eH1
n45E6wibIuwpq2ByLJvTTqmtdGdeheIXx8hewQo2sBEONuSRS32d2KXCDF1Q9y0A
N/LpkpuaijONppaH1iuyGXBdFLxrRTsXnYK/umg2Bk5h38NkkBb1JBxZJWhJ//c2
qEVHtWB9H0ZYO/y7sU8nGPUFnbPnkILWbmnZFfjkXz6VKt0T9NXPO2MDY4thksgz
JmXTIxukZY59BKzYeNJzKKLXqpPq4NS3OUpLXHl2jgFPGQYM0OdSM0gY3Sz27Kw=
=29sf
-----END PGP SIGNATURE-----
On 2014-04-27 09:35, Jeri Raye wrote:
> E486: pattern not found : \c\<\(<C-R>0\)\>
>
> Any idea why pattern isn't found?

It seems to be thinking that the <C-R> is a literal, not a
command to insert a register.

You can try the following, all done as Ex commands rather than
normal-mode commands:

:sview data.txt
:%y a
:let @/='\<\('.substitute(substitute(@a,'\n','\\|','g'), '..$',
'', '').'\)\>\c'
:q
:%s//\u&/g

This should

1) split "data.txt" in a new window
2) yank the whole thing into register "a"
3) make your search register become the transformation of the content
in register-a into the desired search query (wrapped in "\<...\>")
4) close the data.txt window
5) perform the substitution across your entire file, replacing the
first letter with its uppercase variant

-tim

No comments:

Post a Comment