Hi,

Eric Leenman wrote:
> 
> Is it possible to sort lines on line length?
> Shortes firsts, longest last?
> If so how do you do this?

I would put the line lengths at the front of each line with leading
zeroes, sort the buffer, and remove the line lengths.

With Vim 7.0 you can do this with the following commands

  :%s/^/\=repeat('0', 8 - strlen(strlen(getline('.')))) . strlen(getline('.'))/
  :sort
  :%s/^\d\{8\}//

Note the double use of strlen() which is needed to prepends the line
length with the necessary number of zeroes to make it 8 digits wide.

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

Reply via email to