A note to myself: if you have a table of counts and labels, perhaps created by something | something | uniq -c
, you can swap the order of the labels and the counts / change the order of columns in vi via the following regex.
1 2 3 4 |
|
highlight in visual mode with V
then run the following regex: s/\(\d\+\)\s\+\([a-zA-Z0-9_]*\)/\2 \1/
1 2 3 4 |
|
or turn them into the correct format for a python dict via s/\(\d\+\)\s\+\([a-zA-Z0-9_]*\)/'\2': \1,/
1 2 3 4 |
|