How to Sort (numbers) with Vim in VSCode
The aim of this page📝 is to explain how to sort a list of integers in Vim for VSCODE using bash
sort command, something I need sometimes when working with small dataset/markdown tables.
- Select a range in Visual Mode
: to enter Vim command line
!sort -nr to sort the selected range numerically in decreasing order
On Sorting a List of Integers in Bash
- Bash provides the
sort command to sort a list of integers.
- By default,
sort performs a lexicographical sort, which does give the desired result for numbers.
- To sort a list of integers numerically, use the
-n flag with the
-n flag tells
sort to perform a numerical sort.
- To sort the list in decreasing order, use the
-r flag along with the
-r flag reverses the order of the sorting.
- Here’s an example of sorting a list of integers in bash: