Reputation: 160
I have a large table in .adoc ASCIIDoctor format:
|===
|Col A|ColB
|One
|Foo
|Two
|Bar
//... Many fields ...
|===
That renders like:
Col A | Col B |
---|---|
One | Foo |
Two | Bar |
...many | fields... |
I have AsciiDoc
extension installed. If I wanted to insert a new column between A and B, how can I do that without having to manually edit every single field in the whole table?
What did I try? Well, there's nothing to try, I'm doing this manually now as I see no option in VSCode or AsciiDoc Extension to either bulk edit or even a nice GUI like you find in Markdown Extension editors.
Upvotes: 0
Views: 221
Reputation: 160
The best built-in way to manage large tables in an .adoc AsciiDoc file, so far as I've found or asked, is to use the AsciiDoc import feature to import a csv file into a code block, then use a VSCode CSV editor GUI like Edit CSV for editing via a table/cells. This approach is actually more maintainable and better for configuration management anyway, I've found.
To expand on this, if you're okay editing outside of VSCode, you could use/save Excel files instead, edit equations in Excel, and either Save A Copy of .csv files as exports, or have your pipeline run a python script that auto-converts your .xlsx to .csv so your .adoc file can import it.
Upvotes: 0
Reputation: 4521
How do you intend to populate the new column? If you intend to manually update, then you're not really saving much time. If you can script the modification, say to pull values from some data store, you should do that.
If you must solve the problem with VS Code, use the Replace feature with Regular Expression enabled.
Search for \n\n\|(.*)$
, and replace with \n\n|$1|
.
TL;DR: It adds a new empty column after the first column.
The search looks for two line breaks followed by a pipe symbol, then captures everything on the line following the pipe symbol. During replacement, two line breaks and a pipe symbol, followed by the captured characters and an extra pipe symbol. The extra pipe symbol starts a new empty column.
If you "replace all," you'll need to manually fix the table start/end markers and the heading row.
Upvotes: 0