Using vim 6.0.
say I'm editing this file
sdfsdg
dfgdfg
34 12
2 4
45 1
34 5
and I want to sort the second column
Thanks
Using vim 6.0.
say I'm editing this file
sdfsdg
dfgdfg
34 12
2 4
45 1
34 5
and I want to sort the second column
Thanks
If you have descent shell available, select your numbers and run the command
:'<,'>!sort -n -k 2
If you gonna type this in visual mode, after typing the colon, markers '<,'> will appead automatically, and you'll only have to type the rest of it.
This type of commands (:[motion]!) is called filtering. You can learn more by consulting vim's help:
:h filter
For vim7 I would go for:
:sort n /.*\s/
This will sort numbers ignoring text matched by given regexp. In your case it is second column.