Showing posts with label vi. Show all posts
Showing posts with label vi. Show all posts

Thursday, 31 January 2013

Sorting csv files on columns in vim

Nice one, it's actually very easy to sort a [comma or tab or whatever] separated file in vim on a certain column.
The following example
:sort n/\([^\t]*\t\)\{9\}
  • sorts (:sort )
  • a "column" containing *numbers* ( n )
  • defined as anything which is no tab until a tab ( \([^\t]*\t\) )
  • after this having occurred 9 times \{9\} == on the *10th* column.