Friday, October 6th, 2006...4:29 pm
Creating comma delimited lists with vim
Jump to Comments
Sometimes you just want a comma delimited list. But all life has handed you is a newline delimited list. Lucky for us, God made vim.
Paste/Open your file in vim.
Enter command mode (press escape) and enter this command:
:1,$s/\n/,/
That tells vim starting from line 1 to the end of the file replace newlines with commas.
Now we’re golden, you can paste it into an IN clause in your query, or change the replacement to “,” if you want to make a string array for some quick test data without typing like a sucker. And yes vim is available for windows.







1 Comment
April 5th, 2007 at 2:16 pm
If you’re hardcore you use “sed -i -e”; after all, you can’t pipe to vim.
Leave a Reply