Skip to content

Instantly share code, notes, and snippets.

@romainl
Created December 31, 2018 10:30
Show Gist options
  • Save romainl/6351afff54003b3d58c5d9c56f9960e5 to your computer and use it in GitHub Desktop.
Save romainl/6351afff54003b3d58c5d9c56f9960e5 to your computer and use it in GitHub Desktop.
Sort operator
function! Sort(type, ...)
'[,']sort
endfunction
nmap <silent> <key> :set opfunc=Sort<CR>g@
" usage:
" <key>ip
" <key>G
@deurzen
Copy link

deurzen commented May 13, 2019

Alternatively: !<motion/textobject>sort<enter> to leverage GNU coreutils sort. For example: !ipsort<CR>.

@romainl
Copy link
Author

romainl commented Jan 12, 2020

Indeed but :help :sort has a few tricks up its sleeve that GNU sort or BSD sort don't, and it's built-in so it can be used anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment