I'm using vim all the time for text editing these days, and have a particular use case: editing a dataset using successive commands. The main problem, as often, is fixing things, ideally rather quickly.
The picture is this:
- a folder with a number of files, e.g. 1000, that need to be cleaned-up / formatted.
- the cleaning process is quite empirical: checking files, seeing things that need to be changed/erased, thinking of the regex to do it, applying it to the dataset.
The slight issue, however, is that if you try to undo what you just did, by doing
bufdo undo, that command has no memory of the previous batch command, and so if one file was changed by the next-to-last (good) regex, but not by the last (misguided) one you applied because their was no match, then the next-to-last (good) one will be undone, alongside all the undo-s you want in all the files that have been changed by the last misguided regex.
However, there's one thing that I haven't yet come across, which is a way to streamline the use of batch commands like
bufdo so that:
- it is easy and clean to undo (and would lead to a navigable undo tree for the dataset, as it were, not just for individual files).
- maybe it would be possible to see which files have been changed and where are the modifications (seems like a good use for the quickfix/location lists), so that it is possible to apply the regex, go have a quick look to see if everything is fine, before editing further.
I saw somewhere, sadly I can't find it any more now, that I could use git and commit at each step, but that's very slow compared to a do/undo workflow.
Any ideas? Thanks in advance for any feedback! Not sure if I'm confident yet to actually write such a plugin, but leads on how to start doing that could also be welcome.