Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort line (horizontally) in VIM [duplicate]

Tags:

vim

I know that it's very easy to do sort operations in vim through build in command sort. But how to sort just one line and text within that line horizontally?

e.g. from this point (aaa ccc bbb) to this (aaa bbb ccc)

I tried vi(:sort but it doesn't helped me. Any suggestions?

like image 244
hawk Avatar asked Nov 04 '14 16:11

hawk


1 Answers

:s/\s\+/\r/g    " break the line into multiple ones
:'[,sort       " sort them
:,']j          " join them
like image 111
romainl Avatar answered Oct 10 '22 02:10

romainl