-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Currently autoflake
reads from a file by taking a filename, and outputs a diff with a patch to make. This works well for some command line usage, but doesn't integrate so well with replacing a buffer in Vim. This could be improved by offering an option to read the file from stdin, and an option for outputting the entire file contents, with the patch applied, to stdout. stdin support could either by via flag, or by reading a special filename -
. Supposing there was a flag for stdout support, then autoflake
could automatically remove unused imports in Vim with both flags like so.
silent 0,$!autoflake --stdin --output-file
That command would take the contents of the current buffer, pass it to autoflake
via stdin, get the new file after applying the patch back out again, and replace the current buffer with that text.
At the moment, I shall have to save my current buffer to a file, run autoflake
on that temporary file and save the diff to another temporary file, and then use the :diffpatch
command to apply the patch to the current buffer, in order to integrate autoflake
with Vim.