home ~ projects ~ socials

Execute A Shell Command On Multiple Lines In Neovim

This is how you do it with hitting ":" but you can just hit "!" and not have to type it.

  1. Add some text
  2. Select it visually
  3. Hit the :

    It'll show something like:

    '<,'>

  4. Add a ! then the command you want to run. For example, this sorts the selected lines:
'<,'>! sort
-- end of line --