Delete from the current cursor position to a given line number in vi editor

seanhodges picture seanhodges · Jun 17, 2011 · Viewed 71.5k times · Source

How do I delete a block of text from the current cursor row to a given line number in vi?

For example:

 49 <j:set var="changeSet" value="${build.changeSet}" /> <----- delete from here (cursor position)
 50 <j:if test="${changeSet!=null}">
 51   <j:set var="hadChanges" value="false" />
 52   <TABLE width="100%">
 53     <TR><TD class="bg1" colspan="2"><B>CHANGES</B></TD></TR>
 54     <j:forEach var="cs" items="${changeSet.logs}" varStatus="loop">
 55       <j:set var="hadChanges" value="true" />
 56       <j:set var="aUser" value="${cs.hudsonUser}"/>
 57       <TR>
 58         <TD colspan="2" class="bg2">${spc}Revision <B>${cs.revision}</B> by
 59           <B><j:choose>
 60             <j:when test="${aUser!=null}">${aUser.displayName}: </j:when>
 61             <j:otherwise>${cs.user}: </j:otherwise>
 62           </j:choose></B>
 63           <B>(${cs.msgAnnotated})</B>                <----- to here (line 63)
 64          </TD>
 65       </TR>
 66       <j:forEach var="p" items="${cs.paths}">
 67         <TR>
 68           <TD width="10%">

In Vim I would usually use the visual selection mode for this, but I don't have Vim at my disposal on this server. It would also be quicker to specify a line number rather than counting how many lines are within the block in some cases.

Answer

cnicutar picture cnicutar · Jun 17, 2011

You could use something like d63G to delete from the current line until line 63.