Hacker News new | past | comments | ask | show | jobs | submit login
Wrote a post about sorting lines in Neovim, almost wrote an intro to Vim instead (gigatexal.blog)
24 points by gigatexal on May 6, 2023 | hide | past | favorite | 11 comments



I've been using Neovim for years now, and I didn't know about the sort command. Cool trick.

    I still don’t yet know how to list all the available commands (if you know, email me how to do this!)
This command opens the command list in the reference manual:

    :help :ex-cmd-index<return>


For whatever reason in vim 9 and my astro nvim I can’t get the above command to work :shrug:


Ah, I somehow added an extra ':', sorry.

This should work:

    :help ex-cmd-index<return>


gave you a shoutout on the article, thanks again for the feedback. I love learning new things! https://gigatexal.blog/pages/how-to-sort-text-in-place-using...

I don't yet have #anchors to easily navigate but that's a task for another day :sweat_smile:


Thank you!


Beautiful! Thank you!!


Another tip: You can pipe text through shell commands with :! followed by the command.

For example, I always used to use :!sort, until I accidentally dropped the ! once and noticed that it still worked.

Most useful text-processing commands have some native way to do them in Vim, but I often haven't bothered to memorize them, when a shell command is just as easy to type and works in more contexts.


Whoa! Wait. So I can select a bunch of text and then do !sort | uniq … etc ? Very cool.


i just tried it

foo bar baz baz

selected, then !sort | uniq and boom became bar baz foo


I just think it’s funny how my usage of vim is a borderline religion. I’m just so happy with it that I wanna share how to use it with everyone!


sort is one of those things I use fairly rarely (cli or nvim) but man when I need it, it is invaluable. Thanks for sharing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: