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

[no subject]



-Jim P.

On Wed, 2005-05-11 at 17:49 -0400, Greg Freemyer wrote:
> On 5/11/05, Jim Popovitch wrote:
> > Any one have some good examples of sorting from within vi for both a
> > range of lines as well as whole file?
> > 
> Okay dredging up old techniques.
> 
> For the whole file try:
> 
>     Goto to line one:    1G
>     Sort from current line to end of file:    !Gsort<cr>
>     Or if you want to think of it as one command:    1G!Gsort<cr>
> 
> Sort a range:
>     Move Cursor to last line to sort 
>     mark the line with mark 'a':   ma
>     move cursor to first line to sort
>     sort from current line to mark 'a':        !'asort<cr>
> 
> Now what does the special chars above mean.
> 
> '!'  is the vi filter command, it is followed by a movement command
> that says what is being filtered.  That is followed by the actual
> filter cmd.  The filter cmd can be any executable.  In this case sort.
>  Since vi does not know how long the filter command name is, you have
> to hit carriage return to initiate the filter.
> 
> G by itself means go to the end of the file
> 
> ma   means set mark a to this line.   (marks a-z exist)
> 
> 'a   means goto mark a.
> 
> You can use any movement command, but the above are what I normally use.
> 
> HTH
> Greg


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00211" href="msg00211.html">[ale] vi sort question</a></strong>
<ul><li><em>From:</em> jimpop at yahoo.com (Jim Popovitch)</li></ul></li>
<li><strong><a name="00214" href="msg00214.html">[ale] vi sort question</a></strong>
<ul><li><em>From:</em> greg.freemyer at gmail.com (Greg Freemyer)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00214.html">[ale] vi sort question</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00216.html">[ale] Linux App Hosting...</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00214.html">[ale] vi sort question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00216.html">[ale] Linux App Hosting...</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00215"><strong>Date</strong></a></li>
<li><a href="threads.html#00215"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>