Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: convert items on separate lines to a comma-separated list

Tags:

I often paste items separated by newlines or line feeds into an Emacs buffer resulting in each item residing on a different line like this:

one
two
three
four

Very often I actually want a list of comma-separated values like this:

"one", "two", "three", "four"

It would be great to be able to do a one-touch conversion from lines to list. I imagine I can convert this using a regex, but it seems like the kind of commonly used operation that might already have a built-in Emacs function. Can anybody suggest one?