wadetb / Sublime-Text-Advanced-CSV

Efficiently format, edit, arrange, and evaluate cells in CSV files
172 stars 14 forks source link

Support edits on tables embedded in text files #1

Open wadetb opened 10 years ago

wadetb commented 10 years ago

When working in a large Markdown document, sometimes it's nice to quickly paste some text in CSV format and do some calculations on it.

Identify the table either by one of:

  1. Selection
  2. Scanning forwards & backwards from the cursor for a blank line

Maybe provide global modes like "operate on selection" vs "operate on file".

wadetb commented 9 years ago

I'm recently thinking that the best way to implement this is both of the above options.

If there is a selection spanning multiple lines, treat that as the region of text to operate on. Otherwise, scan from the cursor(s) and operate on each surrounding block.

wadetb commented 9 years ago

A more general way to implement this would be:

  1. For each cursor and selection region, extend a region forwards and backwards for the nearest blank line or end of document.
  2. Merge the resultant regions where they overlap.
  3. Apply the command to each region.

Note that for commands which are destructive, we have to be careful that the individual regions work cumulatively (e.g. select column).