MapaDelSitio CambiosRecientes Noticias ÁreaElisp WikiCómo

Sorting

Última vez editado

Resumen: Add SortWords

Modificado:

< See also: SortWords to sort words in a region, and ApplesAndOranges for a way to combine simple predicates for sorting.

a

> '''See Also:'''
> *
ApplesAndOranges for a way to combine simple predicates for sorting.
> * SortWords for sorting the words in a region.


Emacs can sort lines, paragraphs, pages. It can sort by fields, columns or even regexp. There are predefined Emacs commands to all of these things.

‘M-x sort-lines’
Sort lines in the region.
‘C-x h M-x sort-lines’
Sort all lines in the buffer.
‘C-u M-x sort-lines’
Sort lines in the region in reverse order.
‘M-x sort-numeric-fields’
Sort lines in the region numerically.
‘M-x sort-numeric-fields M-x reverse-region’
Sort lines numerically in reverse.
‘M-x sort-paragraphs’
Sort by paragraph in region.
‘C-u M-x sort-paragraphs’
Sort paragraphs in reverse.
‘M-x sort-pages’
Sort by page in region.
‘C-u M-x sort-pages’
Sort pages in reverse.
‘C-u 2 M-x sort-field’
Sort lines by second field in region, where fields are separated by any whitespace.
‘C-u 2 M-x sort-field M-x reverse-region’
Sort lines by second field in reverse.
‘M-x sort-columns’
Sort the lines the region “covers” using the columns between region beginning and end.
‘C-u M-x sort-columns’
Sort lines the region “covers” in reverse using the columns in the region.

In addition to these commands, there are other functions in EmacsLisp available for sorting text. The general ‘sort’ function can sort lists of Lisp objects, see DestructiveOperations or the ElispCookbook for examples.

See nodes ‘Sorting’ in the EmacsManual and ‘Sorting’ in the Elisp manual, for details: Sorting.

See node ‘Rearrangement’ in the Elisp manual for details: Rearrangement.

See Also:


CategoryEditing