Add stdin and stdout options
See original GitHub issueCurrently 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.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:21 (6 by maintainers)
I see. That sounds reasonable then. Welcome aboard!
@myint hi there! If I were to take on this change, would you accept a patch? I can build on #37 or start from scratch, whatever works better (haven’t investigated what will be simpler yet).