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:
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