'How can I pass the current line to a Vimscript function?

I am trying to create a Vim mapping that will operate on the current line, taking a string like this:

[boiled cabbage, mad donkey, elephant, very dark fudge]

And quoting all the list elements to end up with this:

["boiled cabbage", "mad donkey", "elephant", "very dark fudge"]

I tried with vim regexes, but figured it would be easier to write a function that takes the current line as an argument and returns the transformed line. I have no problem performing the transformation in vimscript. But how can I pass the current line to the function, and how do I replace the line with the transformed line?

vim


Solution 1:[1]

You can yank it into a register and then access it from there. "byy yanks the line your cursor is at. You can access it then by using @b

Check out http://vim.wikia.com/wiki/Word_under_cursor_for_command

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Telemachus