I commonly will have a long list of ids that I will need to convert into a tuple for a SQL query or perhaps to create a array in python/javascript. Here is the command I've written to format a list of ids into a tuple and paste it back into the system clipboard:
nnoremap & "*pV']J:s/ /,/g<cr>i(<c-o>$)<esc>V"*y
How could this be converted into a function? I tried starting but I couldn't even get past the first thing of "paste from clipboard", for example:
func FormatInput ()
call execute("\"*p") " how to get this to execute properly with the leading `"` ?
endfunc
While the above one-line might be sufficient for now, I'd like to add things like "quote strings" if the first item is not a digit and stuff like that.
execute()
works in command-mode;p
is a Normal mode command. See:h :normal
– Matt Jun 13 '20 at 10:01