Questions tagged [sort]

Vim command for sorting a set of lines.

Filter by
Sorted by
Tagged with
1
vote
3answers
50 views

reset sequence of numbers

I have 50 lines of code private const CODE = 0; private const DESC = 1; // ... private const TRIM = 19; // instead of 24 private const SMURF = 35; // instead of 25 private const DOG = 31; // instead ...
1
vote
1answer
91 views

function: sort output alphabetically

This function outputs data between braces as joined lines in a quickfix window. The output is sorted based on line numbers. I'm searching for a method to sort the data alphabetically. I tried to ...
3
votes
2answers
116 views

Is there an efficient way to sort a selection of comma separated values in a single line?

I come about this regularly and still do it manually. Consider this example - say it's inside a text. first 3,2,17,198,232,1,999 and some other text second 1,2,3,71,98,4,5 and some more text I ...
2
votes
2answers
153 views

Sorted TODO list with :sort n and letters

Let's say I have ordered TODO list with priorities, sorted already with :sort n similar to : 1. shopping 3. cooking. D 5. car repair. D 11. tap fix. 12. project start D means done. I am using :sort ...
4
votes
1answer
522 views

How to sort lines by the right most characters?

When I enter visual mode, :'<,'>sort allows me to sort alphabetically the lines I have selected, obviously starting from the left most characters on a line going to the right. Is it possible to ...
0
votes
1answer
100 views

How do you sort lines by longest substring to shortest substring?

Here are some sample strings, sorted by longest string to shortest sting: "Bi(NO<sub>3</sub>)<sub>3</sub>·5H<sub>2</sub>O","bismuth nitrate pentahydrate"); "Be(C&...
3
votes
1answer
507 views

How to avoid 'Backwards range given' warning when invoking search range?

I've got the following sample HTML code: <html><body> <table class="foo"> <tr><td>1</td></tr> <tr><td>2</td></tr> <tr><td>...
1
vote
1answer
220 views

How can I sort a file by word frequency?

I have a file containing a list of words, e.g. list.txt contains: carrot apple pen ukulele pen cinnamon carrot carrot How do I sort this file so that the words which appear the most in it go to the ...
10
votes
1answer
513 views

Sorting a column without altering other columns

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-...
6
votes
2answers
390 views

Sort every few lines

I want to sort the following based on their keys case IndexError: PyErr_SetString(PyExc_IndexError, exc.str.c_str()); break; case ValueError: PyErr_SetString(PyExc_ValueError, exc.str....
5
votes
1answer
114 views

In Vim, how can you delete following identical rows in a visual selection, without sorting?

So Lets say I have a list \Summit \SummitSign \sun \ProgrammingOnABoat \SunCloud \SunshineOpenCircled \sup \supdsub \supdsub \supedot \suphsol \suphsub \Summit \SummitSign \sun \Summit \...
4
votes
2answers
401 views

What is the fastest way to sort a paragraph?

You can reflow a paragraph with gqip (or gqap). Is the fastest way to sort a paragraph vip:sort<cr>? Or is there some shorter keystroke for sorting?
3
votes
1answer
256 views

Sorting a list in the buffer?

Is there a way to sort a list (single column, each item separated by \r) in the buffer using just vim?
11
votes
1answer
2k views

Sort based on comma separated words

Normal command :sort can sort lines based on column or virtual column (\%c or \%v), could the higher level logical column be used as sorting key? Using regular expression looks a little complex for ...
4
votes
1answer
420 views

User-defined sorting precedence

Is there a way to define a sorting precedence regarding the line's pattern and then use it with :sort? For example, if I have these lines: 1 some text (foo) some other text 2 some text (bar) some ...