[CentOS] Vim scripting - cursor motion
Les Mikesell
lesmikesell at gmail.com
Thu Jun 9 15:37:21 UTC 2011
On 6/9/2011 10:07 AM, Jussi Hirvi wrote:
> On 9.6.2011 18.01, m.roth at 5-cent.us wrote:
>> Why do vim scripting? That's what sed, or awk, or perl, are for. The
>> latter two, of course, are much easier to comprehend the logic, too.
>
> Maybe just because I know vim better than sed, awk or perl, which I
> haven't used at all. :-)
The regexp parts will just have minor syntax differences.
> The practical purpose is to turn a tabtext file into CSV
> (comma-separated) to be used in a SQL insert statement.
I'd highly recommend perl for this because it can also do the SQL part
directly via DBI without all of the intermediate contortions you'll have
to do in files otherwise. It should take about half a page of your own
code to connect to the DB, read the file, transform it line-by-line to
sql and execute the sql statements. And unlike other approaches with a
pipeline of different tools, you can generate sensible error messages in
the right places that have something to do with the input.
--
Les Mikesell
lesmikesell at gmail.co
More information about the CentOS
mailing list