Re: - OT - VIM - recording

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Jul 15, 2009 at 12:01 PM, Charles E Campbell
Jr<charles.e.campbell@xxxxxxxx> wrote:
> Ed Donahue wrote:
>> Is it possible in vim to do the following:
>>
>> Search for this block of data:
>>
>>         # Catalog Service 2.0 for uat03
>>         <LocationMatch "^/Services/?">
>>         PathPrepend /inquiryservices
>>         Cluster 172.21.1.1:999
>>         </LocationMatch>
>>
>> And change Cluster 172.21.1.1:9999 to Cluster 172.21.1.2:7000
>>
>> It needs to have uat03 (or 02, 01) on the line and this line
>> 'PathPrepend /inquiryservices' for the Cluster to be changed.
>>
> Yes.  Embed following into a file, have cursor above any blocks you want
> changed, and source this:
>
> let uat= search('^\s*#\s*Catalog.*uat0[123]$','W')
> if uat
>  if getline(uat+1) =~ '<LocationMatch\>'
>  let hasprepend = search('^\s*PathPrepend /inquiryservices','Wn')
>  let lmend      = search('^\s*</LocationMatch\>','W')
>  if lmend && hasprepend
>   exe uat+1 "," lmend-1 "s/Cluster 172.21.1.1:9999/Cluster
> 172.21.1.2:7000/e"
>  endif
>  endif
> endif
>
> That's a one shot change.  You could wrap this into a function or map
> and call it as often as wished.
>
> I suggest asking vim questions on the vim mailing list, BTW.  See
> http://vim.sourceforge.net/community.php .  You might get a better
> answer than mine there, too.
>
> Regards,
> Chip Campbell
>
> --
> someday I'll have a good signature, I'm sure of it...
>
> _______________________________________________
> CentOS mailing list
> CentOS@xxxxxxxxxx
> http://lists.centos.org/mailman/listinfo/centos
>

Wow, thank you!
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux