SublimeText / ElasticTabstops

Tab characters automatically adjust to keep adjacent lines aligned.
https://github.com/SublimeText/ElasticTabstops
67 stars 6 forks source link

Remove added spaces (on save) #10

Open deanishe opened 10 years ago

deanishe commented 10 years ago

I write a lot of vocab lists and the TSV format with ElasticTabstops makes that very pleasant. The auto-alignment is very helpful for editing. But I'd like to be able to save the files without the extra spaces, so the saved files are valid.

I wrote a simple plugin to do this myself, but newer versions of ElasticTabstops fire immediately after my plugin runs, putting all the spaces back in :(

Would it be possible for ElasticTabstops to have a remove_spaces_on_save option, so correct TSV files are saved, and the spaces are only added to help with editing?

adzenith commented 10 years ago

Would you be up for merging your plugin into ElasticTabstops and sending a pull request? Thanks!

deanishe commented 10 years ago

My plugin is not good enough to be merged into ElasticTabstops. It is basically broken for anything beyond my very simple needs—it just naively mashes the text through csv.reader and csv.writer.

I'm honestly not sure how I would go about doing it properly (i.e. not deleting spaces inside quotes etc.)

adzenith commented 10 years ago

If I were writing it, I wouldn't make it tsv-aware (i.e., ignoring quotes and so forth), I would simply search for something like the following regex:  +\t and replace it with a tab character. I would do it this way because the formatting isn't tsv-aware (i.e. it also breaks if you put a tab inside of quotes).