VI Application: Use the V and S command to extract the desired content in two steps

Source: Internet
Author: User

This article explains how to use the V and S commands of VI to extract the desired content using the ID of all the beans in the Applicationcontext.xml configuration file in spring.

The contents of the Applicationcontext.xml file are as follows:

<?xml Version = "1.0" encoding = "UTF-8"?>

<beans xmlns = "Http://www.springframework.org/schema/beans"

Xmlns:xsi = "Http://www.w3.org/2001/XMLSchema-instance" Xmlns:context = "Http://www.springframework.org/schema/context"

xsi:schemalocation = "Http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

Http://www.springframework.org/schema/context

Http://www.springframework.org/schema/context/spring-context-2.5.xsd ">

<bean id= "bookservice" class = "Bookserviceimpl" >

<property name = "Appprofile" ref= "Myprofile" >

</property>

</bean>

<bean id= "libservice" class = "Libserviceimpl" >

<property name = "Triggers" >

<list>

< ref local = "Bookservice"/>

</list>

</property>

<property name= "Threadcountproperties" >

<props>

< prop key = "ThreadCount" > 1</prop >

</props>

</property>

</bean>

</beans>

The goal is to extract the Bean IDs (Bookservice and Libservice). The steps are as follows:

1) Use the v command to delete lines that do not contain <bean\

: v/<bean\/D

The Applicationcontext.xml content becomes as follows:

<bean id= "bookservice" class = "Bookserviceimpl" >
<bean id= "libservice" class = "Libserviceimpl" >

2) Use regular expressions with the S command to replace each line with what we want to propose

:%s/.\{-\}id= "\ (. \{-\}\)". *$/\1

The Applicationcontext.xml content becomes as follows:

Bookservice
Libservice

At this point, two bean IDs (Bookservice and Libservice) were successfully extracted.

This method will modify the original text content, in order not to affect the original text, please copy a copy specifically used to extract information. In addition, this is just a more comfortable way for people to use, if you have a better way to discuss together.

VI Application: Use the V and S command to extract the desired content in two steps

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.