I was recently aware of the filtering !
technique, and I love it. Unfortunately, I am not able to use it in a visual-block mode. Hope some experts here would help me out.
Basically, I want to in-place sort a column such as the third below (just a MWE). And I don't want to disturb the other columns when I sort.
I tried to filter (!
) the visually (block-mode) selected third column through sort
utility. But the sort rather extends beyond selection i.e. all of the rows are swapped, not just the selection, that too sorting based on the first column!
1. LARGEST 40
2. SECOND-LARGEST 168
3. MID 2.8
4. MID 540
5. MID 14.84
6. MID 40
7. SECOND-LEAST 64
8. LEAST 8
I selected last column using visual-block, and said !sort --reverse
which shows up as
'<,'>!sort --reverse
And the result is strange opposed to what I expected. The result has the entire rows sorted/swapped, not just one column, and that too, based on the first column irrespective of my third-column selection!
8. LEAST 8
7. SECOND-LEAST 64
6. MID 40
5. MID 14.84
4. MID 540
3. MID 2.8
2. SECOND-LARGEST 168
1. LARGEST 40
Unless impossible otherwise, I would like a pure vim+sort solution, rather than the relatively advanced tools such as sed
/awk
. It is more importantly to know myself, how limited the visual-block mode is, compared to say, visual-mode.
sort
command available, so you don't need to invoke the external!sort
for doing a regular sort.:help filter
) but also standardized (sorry, I don't know how to deep-link that POS). You can't complain if you don't RFTM.