How to get line numbers of selected text in vim
Is it possible to pass line numbers of selected text to an external command?
Context: I would like to integrate pyfmt
into vim. Ideally, I would like to select the text and type some shortcut so that the selected text is formatted pyfmt
.
So far, I've found that launching !pyfmt -i %
will format the entire file. pyfmt
also supports the parameter --lines START-END
. I would like to be able to pass line numbers from the start and end of the selected text to pyfmt
, so that only the reformatting will be fixed. Is it possible?
source to share