Groups | Search | Server Info | Login | Register


Groups > gnu.emacs.help > #60692

Re: Sort from second field instead on second field

From HASM <hasm@example.invalid>
Newsgroups gnu.emacs.help
Subject Re: Sort from second field instead on second field
Date 2023-03-29 09:39 -0700
Organization A noiseless patient Spider
Message-ID <87a5zva4vk.fsf@127.0.0.1> (permalink)
References <87sfdnlfkj.fsf@munus.decebal.nl>

Show all headers | View raw


> You can sort lines in the region on the second field with:
>     C-u 2 M-x sort-field
> In most cases this will probably be enough. But what if I would want
> to sort from the second field to the end of the line?

Silly recipe:

- mark at the first char of the first line of the region

- go to last char of the last line of the region

- M-x untabify

- add enough spaces to the first line of the region to make it as long
  as the longest line in the region 

- go to end of the first line, and mark

- go to the beginning of the second field on the last line

- M-x sort-columns

Replace region with full buffer, if that's what you need
First and last line can be reversed above
Use C-u M-x sort-columns to reverse the sort order, as usual

-- HASM

Back to gnu.emacs.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-29 17:53 +0200
  Re: Sort from second field instead on second field HASM <hasm@example.invalid> - 2023-03-29 09:39 -0700
    Re: Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-29 19:55 +0200
  Re: Sort from second field instead on second field Ralf Fassel <ralfixx@gmx.de> - 2023-03-29 19:28 +0200
    Re: Sort from second field instead on second field Cecil Westerhof <Cecil@decebal.nl> - 2023-03-30 07:03 +0200

csiph-web