{"id":186,"date":"2008-07-21T15:01:52","date_gmt":"2008-07-21T23:01:52","guid":{"rendered":"http:\/\/jim-zimmerman.com\/blog\/?p=186"},"modified":"2008-07-22T08:05:52","modified_gmt":"2008-07-22T16:05:52","slug":"sort-from-within-vi","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=186","title":{"rendered":"Sort from within vi."},"content":{"rendered":"<p>Source: http:\/\/www.ale.org\/archive\/ale\/ale-2005-05\/msg00214.html<\/p>\n<p>For the whole file try:<\/p>\n<p>    Goto to line one:  <em>1G<\/em><br \/>\n    Sort from current line to end of file:    <em>!Gsort<\/em><cr><br \/>\n    Or if you want to think of it as one command:    <em>1G!Gsort<\/em><cr><\/p>\n<p>Sort a range:<br \/>\n    Move Cursor to last line to sort<br \/>\n    mark the line with mark &#8216;a&#8217;:   <em>ma<\/em><br \/>\n    move cursor to first line to sort<br \/>\n    sort from current line to mark &#8216;a&#8217;:        <em>!&#8217;asort<\/em><cr><\/p>\n<p>Now what does the special chars above mean.<\/p>\n<p>&#8216;!&#8217;  is the vi filter command, it is followed by a movement command<br \/>\nthat says what is being filtered.  That is followed by the actual<br \/>\nfilter cmd.  The filter cmd can be any executable.  In this case sort.<br \/>\n Since vi does not know how long the filter command name is, you have<br \/>\nto hit carriage return to initiate the filter.<\/p>\n<p>G by itself means go to the end of the file<\/p>\n<p>ma   means set mark a to this line.   (marks a-z exist)<\/p>\n<p>&#8216;a   means goto mark a.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: http:\/\/www.ale.org\/archive\/ale\/ale-2005-05\/msg00214.html For the whole file try: Goto to line one: 1G Sort from current line to end of file: !Gsort Or if you want to think of it as one command: 1G!Gsort Sort a range: Move Cursor to last line to sort mark the line with mark &#8216;a&#8217;: ma move cursor to first line [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-documentation"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=186"}],"version-history":[{"count":0,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/186\/revisions"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}