vis
vis copied to clipboard
Retab function: automatically format code based on syntax
There's a retab function in Sublime, which re-formats code based on syntax - it detects automatically the levels of nesting and inserts tabs or spaces accordingly.
Is it possible to implement something like this with lexers? And if not, what can be done?
You can just use any stand-alone formatter in vis, binding it to a key or calling it on save. For instance, I have ";c" bound to cargo fmt the current file.
:|indent -kr<CR>
Done. Works even on selection.