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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityYou could define a "sort lines" operator like this:
function! s:SortLinesOpFunc(...)
'[,']sort
endfunction
nnoremap <silent> \s :<C-u>set operatorfunc=<SID>SortLinesOpFunc<CR>g@
\sip
will sort the paragraph under the cursor and, in general, \s{motion}
will sort the lines moved over by {motion}
, inclusively.
See :help :map-operator
.
You can create a simple normal mode mapping:
nnoremap <key> :'{,'}sort<CR>
usage from normal mode: <key>
or a more flexible visual mode mapping:
xnoremap <key> :sort<CR>
usage from normal mode: vip<key>
:helpgrep sort
didn't turn up anything in the change.txt file)